Python ends in the middle

Asked 2 years ago, Updated 2 years ago, 62 views

The upper code was cleared in the middle. I want to end the program execution in two parts of the shop. Please let me know.

list_input = []

while True:

    x = input ("Enter a positive integer"). : ")  

    intornot = isint(x)
    if (intornot == False) : 
        if int(x)<0 :
            break
        else : 
            list_input.append(x)
    else :
        print("The character entered is not a positive integer. Please re-enter it.")
       ## I want to shut it down in the middle here so that the code outside of this repeat door doesn't run. 
        break
if x != '' and list_input != []: 

    print("Maximum value is",my_max(list_input)))
    print("Minimum value is", my_min(list_input)))
    print("sum" my_sum(list_input))
    print("mean is",my_avg(list_input)))


else :

    print("The character entered is not a positive integer. Please re-enter it.")

python loops

2022-09-20 17:03

1 Answers

Rather than having a different grammar, I think we should organize the if statement in a different way.

If you want to terminate in else so that you don't execute code below else statement, you can put code below else statement in if statement.


2022-09-20 17:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.