-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
text_file = open("/Users/dchase/Desktop/text_file.txt", "r") #Creates a reference to our file, for "r" reading | ||
|
||
textFromFile = text_file.read() #Reads our entire file into a variable as a string | ||
|
||
foes = textFromFile.split(',') #split() uses the , in our string to create an array | ||
|
||
for foe in foes: | ||
|
||
if foe == 'Joker': | ||
print 'Why so serious?' | ||
else: | ||
print foe | ||
|
||
|
||
# for i in range(0,len(foes)): #iterate over a range of numeric values | ||
# | ||
# if foes[i] == 'Deathstroke': | ||
# | ||
# print 'Slade. The one-eyed wonder.' | ||
# | ||
# elif foes[i] == 'Clayface': | ||
# | ||
# print "Clayface. Easily bent out of shape." | ||
# | ||
# else: | ||
# | ||
# print foes[i] | ||
|
||
# for index, value in enumerate(foes): # iterate over the array while having access to the current index and current value | ||
# | ||
# if value == 'Bane': | ||
# print 'Bane. The man who broke the bat.' | ||
# else: | ||
# print foes[index] | ||
# |