Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to break a while loop when users enter nothing [closed]

$
0
0

The if statement should print "good" and break when I hit enter but instead, it keeps asking for input with no error. Does anyone know what is wrong with the code?

input_list = []while True:    input1 =  input("Exam points and exercises completed: ")    if input1 == "":        print("good")        break    else:        input1 = list(map(int, input1.split(" ")))        def finding_x(input1):            x = input1[0]             if x < 10:                return 0            else:                return x        def finding_y(input1):            y = input1[1]            if y < 10:                return y            else:                y = int(( (y // 10) * 10 ) / 10) # or use y = y - (y % 10)                   return y        input_list.append ([finding_x(input1), finding_y(input1)])print (input_list )

The expected result should be the input_list with values going through 2 def. When entering an empty input it should print "good" and break and stop asking for input.Edit: My code works fine when i switch to n online intepreter instead of VSC. The problem is in the VSC and i do not know what it is


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>