0
How do I end this while true statement
while True: num = input('Enter age for all users separated by a comma: ') n = num.split(',') print(n) if len(n) >= 2: for i in range(len(n)): highest = max(n) lowest = min(n) print('Oldest person: ' + highest) print('youngest person: ' + lowest) else: print("Please, at least enter 2 numbers separated by ','")
5 Answers
+ 1
add a break statement where you want to end it.
+ 1
Show us the code from the code playground.
Share the code link here and will edit it and solve the issue
0
I did but dint work
0
While True:
i=0
while i<100:
i = i+1
break
Attention to identation!
0
when do you want to end loop?
if you only want once iteration, you doesn't need the while line...
if you know how many, you should use a counter to break when it reach 0 (initialized with number needed, decremented at each iteration)
if you want to break on user specific input, you should add a test to verify if user want to end, then break
also, if you use nested loop, you must break each nested loops between targeted loop to be broken and actual loop...