This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| the_count = [1, 2, 3, 4, 5] | |
| fruits = ['apples', 'oranges', 'pears', 'apricots'] | |
| change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] | |
| #this first kind of for-loop goes through a list | |
| for number in the_count: | |
| print "This is count %d" % number | |
| #same as above | |
| for fruit in fruits: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| i = 0 | |
| numbers = [] | |
| while i < 6: | |
| print "At the top i is %d" % i | |
| numbers.append(i) | |
| i += 1 | |
| print "Numbers now: ", numbers | |
| print "At the bottom i is %d" % i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| animals = ['bear', 'tiger', 'penguin', 'zebra'] | |
| bear = animals [0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sys import exit | |
| def gold_room(): | |
| print "This room is full of gold. How much do you take?" | |
| next = raw_input(">") | |
| if "0" in next or "1" in next: | |
| how_much = int(next) | |
| else: | |
| dead("man, learn to type a number.") |
NewerOlder