Skip to content
Advertisement

When using the method while, it throws an error Name error [closed]

When using the method while, it throws an error Name error…This error “while running: NameError: name ‘running’ is not defined”.Help me please!Thanks!

number=25
running:True

while running:

guess=int(input('Is your number:'))
  
if  guess == number:
print('Yea!')
      running=False
elif guess > number:
print('No')
else:
print('No')

Advertisement

Answer

replace : with =

running=True

It will work for you

number=25
running=True

while running:
    guess=int(input('Is your number:'))
    if  guess == number: 
        print('Yea!')
        running=False
    elif guess > number:
        print('No')
    else:
        print('No')
Advertisement