Jump to content

Python help

Bego232
Go to solution Solved by Sauron,

First of all "input()" returns a string unless you specify you want something else. That means no matter what you write, a string is never going to be equal to the integers 1, 2 or 3 for python. Try

number = int(input("Enter number: "))

Hello,

 

I am trying to make a basic number programme on Python.

 

Here is my code.

number = input("Enter number: ")if number == 1:    print("\n\nI like the number 1 too")elif number == 2:    print("\n\nI like the number 2 too")elif number ==3:    print("\n\nI like the number 3 too")else:    print("\n\nThat number doesn't count!")input("\n\n\nPress enter to exit")

For some reason, whatever number I type, it prints:

That number doesn't count!

If anyone could help, it would be great.

 

Thanks,

 

- Bego :)

Link to comment
Share on other sites

Link to post
Share on other sites

First of all "input()" returns a string unless you specify you want something else. That means no matter what you write, a string is never going to be equal to the integers 1, 2 or 3 for python. Try

number = int(input("Enter number: "))

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

 

First of all "input()" returns a string unless you specify you want something else. That means no matter what you write, a string is never going to be equal to the integers 1, 2 or 3 for python. Try

number = int(input("Enter number: "))

Thanks :D

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×