Nameerror: name 'input' is not defined

Asked

Viewed 1,034 times

0

I don’t understand the error in this code...

def checkio(number):
    #Your code here
    #It's main function. Don't remove this function
    #It's using for auto-testing and must return a result for check.

    number = int(input("Escolha um numero: "))

    while number > 0 and number <= 1000:
        if number % 3 == 0:
            print ("Fizz")
        elif number % 5 == 0:
            print ("Buzz")
        elif number % 3 == 0 and number % 5 == 0:
            print ("Fizz Buzz")
        else:
            print ("É um outro numero!")

    return str(number)

checkio(17)
  • 1

    Got to put the most complete code, I think this missing call the checkio, but there’s no way of knowing how he used it.

2 answers

2

Try to run like this:

python nome_do_seu_arquivo.py

I don’t know if you’re calling the file directly.

1

You must be using Python2 and not 3, to work in Python2 you must use raw_input

Change this:

number = int(input("Escolha um numero: "))

For:

number = int(raw_input("Escolha um numero: "))

If you are going to migrate to 3 then use the input

Browser other questions tagged

You are not signed in. Login or sign up in order to post.