0

How to fix EOFError

print("You are your friends want to go clubbing") print("The club you arrive at is 18+") person = 1 while(True): print("\nThe bouncer asks person %d of your group how old they are?" % person) age_of_person = int(input("Enter their age:")) if(age_of_person > 18): print("\nThe bouncer allows person %d of your group into the club" % person) else: print("\nPerson %d of your group was refused entry into the club" % person) person += 1 Output: You are your friends want to go clubbing The club you arrive at is 18+ The bouncer asks person 1 of your group how old they are? Enter their age: Person 1 of your group was refused entry into the club The bouncer asks person 2 of your group how old they are? Enter their age: Person 2 of your group was refused entry into the club The bouncer asks person 3 of your group how old they are? Enter their age: The bouncer allows person 3 of your group into the club The bouncer asks person 4 of your group how old they are? Enter their age: Traceback (most recent call last): File "..\Playground\", line 7, in <module> age_of_person = int(input("Enter their age:")) EOFError: EOF when reading a line

8th Jan 2017, 8:57 PM
Andrew Rivera
Andrew Rivera - avatar
1 Odpowiedź
+ 1
when dealing with errors use a try-except block try: #code except EOFError: #exception code
28th Mar 2017, 10:46 PM
Logan New
Logan New - avatar