def main():
# This code reads in data.txt and loads it into an array
# Array will be used to add friends, remove and list
# when we quit, we'll overwrite original friends.txt with
# contents
print"Welcome to the program"
print "Enter the correct number"
print "Hockey fan 1, basketball fan 2, cricket fan 3,Numbers of favorite players-4"
choice = input("Select an option")
while choice!=3:
if choice==1:
addString = raw_input("Who is your favorite player??")
print "I love Kessel"
elif choice==2:
remInt = raw_input("Do you think that the Cavaliers will continue ther loosing ways?")
print "I think they can beat the Clippers"
else:
inFile = open('data.txt','r')
listNumbers = []
for numbers in inFile:
listNumbers.append(numbers)
print numbers
inFile.close()
print "Cricket is a great sport"
def quit():
Print "Quitting Goodbye!"
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
如果这真的是你的代码,那么你的代码print就是大写的.
print "Quitting Goodbye!"
另外,我刚刚运行了你的代码,你的else子句中有一些不正确的缩进:
inFile = open('data.txt','r')
listNumbers = []
for numbers in inFile:
listNumbers.append(numbers)
print numbers
inFile.close()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
603 次 |
| 最近记录: |