So I am writing a program but terminal is giving me a syntax error and some other websites are giving me EOF errors. Also if I enter a string it gives me a error even though I put a ValueError in my code. How can I fix this.
while True:
try:
a = (input("Enter 15 numbers: ").split())
a = [int(i) for i in a]
b = sorted(a)
c = False
except ValueError:
print("Please enter a number.")
continue
if len(b) > 15 or len(b) < 15:
print("Please enter exactly 15 numbers")
else:
c = True
break
if c == True:
print("Hello")
else:
bob = 1
print("done")
EOF Error:
$python main.py
Enter 15 numbers: Traceback (most recent call last):
File "main.py", line 3, in <module>
a = input("Enter 15 numbers: ").split()
EOFError: EOF when reading a line
Syntax Error:
a = (input("Enter 15 numbers: ").split())
File "<string>", line 1
1 1 1 1 1 2 2 2 2 2 3 3 3 3 3
^
SyntaxError: invalid syntax
String Error:
File "inp.py", line 3, in <module>
a = (input("Enter 15 numbers: ").split())
File "<string>", line 1, in <module>
NameError: name 'd' is not defined