i want to get a loop if we accidently input an alphabet

Viewed 25
#if we put an alphabet in 'x' it should loop infinite times

x = str(input("put number here: "))

so I wanna loop x statement in python if we put an alphabet in x and I've been at it for the past month but all i'm getting is for loop and those continue loops, I've tried them but they don't work (at least with my brain) so please some help would be appreciated.

1 Answers

I'm not sure I've got you right
but maybe you're looking for something like this:

while variable := input("put number here: "):
    if not variable.isalpha():
        break

this code places user's input inside variable and do it only if input is not [a-zA-Z]

Related