2011-02-11 2 views
0
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() 
+0

안녕 줄기가 –

+0

라고 대답하는 줄은 42입니다. – powtac

답변

7

이것이 실제로 코드 인 경우 print은 대문자입니다.

inFile = open('data.txt','r') 
listNumbers = [] 
for numbers in inFile: 
    listNumbers.append(numbers) 
    print numbers 
inFile.close() 
1

는 "인쇄"를 소문자 시도 :

print "Quitting Goodbye!"

또한, 나는 당신의 코드를 실행, 당신은 당신의 else 절에 일부 부적절한 들여 쓰기가? {적어도 30 자 이상이면 무시하십시오}

1

대문자로 표시된 print 문을 작성했는지 확인하십시오. print이 아니라 Print이어야합니다.

관련 문제