0

I'm creating a program in python that involves integers and i want a piece of code to work like this:

num = int(input("Select a number: "))
while num != (1 or 2 or 3):
    num = int(input("Select a number: "))

PLease can you give me the correct code for this, Thanks

user2916424
  • 37
  • 1
  • 1
  • 3
  • 1
    StackOverflow isn't so much of a "make me this code" thing as a "how do I make my code better" thing; Can you show us what you've tried so far? At the very least, it gives us context and helps us know what you understand/don't understand, so our answers are more useful to you. – jwarner112 Oct 24 '13 at 15:13

2 Answers2

1

You need to use in here:

while number not in (1, 2, 3):
1

For the part of asking for numbers check raw_input.

For the while loop, you can check while loop.

Jblasco
  • 3,827
  • 22
  • 25
  • The OP might be on Python 3, using `input()` correctly. And his while loop is OK, the condition isn't. So this answer is not really helpful. – Tim Pietzcker Oct 24 '13 at 15:37
  • 1
    It is simply out of date, Tim Pietzcker. The post has been changed since I wrote it ;). But I do accept that I should have put a link to the Python 3 versions of the manuals. – Jblasco Oct 24 '13 at 15:42