lec-10-28

lec-10-28 - 10/27/2009 break Ends the whole loop. while...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
10/27/2009 1 ECS 10 10/26 break ± Ends the whole loop. while True: reply = raw inpu (“Enter Y or N: “ reply = raw_input( Enter Y or N: ) if (reply == “Y”) or (reply == “N”): break print “You answered”,reply,”.” continue ± Goes back to the top of the loop. string = “3,492,043” for char in string for char in string: if char == “,”: continue output = output+char print output What’s the difference? ± break goes DOWN; breaks the whole loop. ± continue goes UP; continues the loop. ± Both can be tricky to use, and they both make your programs harder to decipher your programs harder to decipher. Database ± Let the user look up specific piece of data. ± Example: state populations. What is the population of Oregon? ± One way to do it One way to do it: User picks a state for line in stateFile: if state in line: find population This does not “scale up” ± When there is one question per program and the list of data is short, this is an OK plan. ± But what if SISWeb worked like this? Every
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/14/2010 for the course ECS 10 taught by Professor Amenta during the Spring '07 term at UC Davis.

Page1 / 3

lec-10-28 - 10/27/2009 break Ends the whole loop. while...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online