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
| #Leo, I found a better way. Look where I moved the int() call to: | |
| r, c = [int(c) for c in user_input if c.isdigit()][:2] | |
| # r = int(r) | |
| # c = int(c) |
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
| import os | |
| import time | |
| from random import randint | |
| os.system('cls' if os.name == 'nt' else 'clear') | |
| DOWN = "Down" | |
| RIGHT = "Right" | |
| DESTINATION = "Destination!" | |
| EMPTY_CHAR = "[ ]" | |
| OBSTACLE_CHAR = "[X]" |
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
| ''' | |
| This is hacky and ugly. It only works because both | |
| lists are the same size, etc. etc. | |
| Upon researching this, it seems that this is an example | |
| when map() is actually way better and preferable. | |
| There's also a function called zip() which does this, | |
| but I haven't learned zip() yet. |
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
| FILES = ["picture1", "georgi_paws_everywhere", "custom_wreath"] | |
| results = ["{}.jpg".format(file) for file in FILES] | |
| print results | |
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
| NUMBERS = range(4) | |
| NAMES = ['Rebecca', 'Georgi', 'Reed', 'Thom Yorke'] | |
| def my_map(function, iterable): | |
| output = [] | |
| for element in iterable: | |
| result = function(element) |
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
| FILES = ["picture1", "georgi_paws_everywhere", "custom_wreath"] | |
| def my_map(function, iterable): | |
| output = [] | |
| for element in iterable: | |
| result = function(element) | |
| output.append(result) |
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
| def my_map(function, iterable): | |
| output = [] | |
| for element in iterable: | |
| result = function(element) | |
| output.append(result) | |
| return output |
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
| def my_filter(function, iterable): | |
| output = [] | |
| for item in iterable: | |
| if function(item): | |
| output.append(item) | |
| return output |
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
| >>> tuple = ('fashion', 'nugget') | |
| >>> tuple[0] | |
| 'fashion' | |
| >>> tuple[1] | |
| 'nugget' | |
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
| >>> string = "Reed Dunkle" | |
| >>> string.startswith('Reed D') | |
| True | |
| >>> string.startswith('Re') | |
| True | |
| >>> string.startswith('Reed W') | |
| False | |
| >>> |