how to i loop the script so i can keep entering my options without an error on python [closed]

StackOverflow https://stackoverflow.com/questions/11729964

  •  23-06-2021
  •  | 
  •  

문제

print'Personal information, journal and more to come'
x = raw_input()
if x ==("personal information"): 
 print' Edward , Height: 5,10 , EYES: brown , STATE: IL TOWN:  , SS:'
if x ==("journal"):
 read = open('C:\\python\\foo.txt' , 'r')
 name = read.readline()
 print (name)

how do i loop or keep this code running without telling me that something wasnt defined? for example if i type in personal information and i get to my personal information then i want to type journal and then go to journal?

도움이 되었습니까?

해결책

I don't know what really is your problem, but this should be helpful:

print'Personal information, journal and more to come'
while True:
    x = raw_input()
    if x =="personal information": 
        print' Edward , Height: 5,10 , EYES: brown , STATE: IL TOWN:  , SS:'
    elif x =="journal":
        read = open('C:\\python\\foo.txt' , 'r')
        name = read.readline()
        print (name)
    else:
        break
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top