I am making a Python program for a school project and I want to say: 'If input is <enter> break'. I tried to write:
a = input('>')
if a == '\n':
break
and it didn't work. How do I fix this?
I am making a Python program for a school project and I want to say: 'If input is <enter> break'. I tried to write:
a = input('>')
if a == '\n':
break
and it didn't work. How do I fix this?
This is your desired code. It breaks the loop when you only press the enter button as input:
while True:
a= input()
if a =='':
break
else: continue