the .isnumeric loop to check if it is a number blocks the loop under it which is while not equal to ‘____’ since I had put an int under it.

This is my code

while star == '':
    print('Invalid speed.')
    star = input('Enter shooting star speed in km/s: ')


#checks if the user had input a number
while not star.lstrip('-').isnumeric():
    print('Invalid speed.')
    star = input('Enter shooting star speed in km/s: ')
star = int(star)


#if the user has input final it will stop
while star != 'final': #(!!!!)
    if star < 12:
        survivestar_list.append(star)
    else:
        faststar_list.append(star)  
    star = input('Enter shooting star speed in km/s: ')
    while not star.lstrip('-').isnumeric(): #checks if the user had input a number
        print('Invalid speed.')
        star = input('Enter shooting star speed in km/s: ')
    star = int(star)

I want it so when the user types final it stops the code?

New contributor

sou1x is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Khám phá các thẻ bài đăng