0

for example x is an int

if x==(user presses enter without value input)
y=1

How do i get the code to accept that value?

1 Answer 1

0

Presumably you would read an empty string in that case. An empty string is falsy, so you can use the following:

if not x:  # i.e. if "user gave no input"
    ...

You should perform that check before parsing x as an int.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.