General Question

chk8n's avatar

How to check for user input for both intergers and to see whether user select numbers in between 0-200? Python?

Asked by chk8n (106points) February 3rd, 2011

User has to input a number (no letters or characters), and has to be between 0–200. Otherwise I want to inform the user to re enter the numerical answer based on these requirements.

Basically if a user put “a” instead of a number, I want the error to print “give number between 0–200”- or if user put “300”, same error pops up.

How do I do that?
If anyone can provide a detailed answer, it will be perfect.
Im in beginner level in high school.

Thank you!

Observing members: 0 Composing members: 0

2 Answers

bobbinhood's avatar

I think the section under “Checking the Content of String Objects” on this page will give you the information you need. I don’t dare try to summarize it since I’ve never used Python.

cbloom8's avatar

You’re looking at a few if/else if (elif?)/else statements – basically going through the options. If the input isn’t right (not right type or not in range) then print out, but if right, then move on to the next step. I don’t remember the exact syntax, but that is what you’ll have to use.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther