while True:
inputstring = input("Enter input string: ")
"\n"
if (inputstring == 'q'):
break
if ',' not in inputstring:
print("\nError: No comma in string.")
else:
fname , sname = inputstring.split(',')
fname , sname = fname.strip(), sname.strip()
print("\nFirst word:", fname)
print("Second word:", sname)
print("\n")
Enter input string: Traceback (most recent call last):
File "main.py", line 2, in <module>
inputstring = input("Enter input string: ")
EOFError: EOF when reading a line
答案 0 :(得分:0)
将第3行更改为'print(“ \ n”)'