Oct-30-2022, 08:40 PM
Pages: 1 2
Oct-30-2022, 09:02 PM
i think i have got it, thank you !
Oct-31-2022, 06:09 AM
(Oct-30-2022, 07:46 PM)astral_travel Wrote: [ -> ]okay thank you Dean,That is not the kind of questions you should be asking. You should figure that out by yourself. I assume you are using some sort of IDE that allows single stepping through programs. If not, download one immediately! Using the debugger in your IDE, single step through the program. When is the message printed? Was it when the variable is assigned or somewhere else?
i have a question for you, - i noticed that on lines 14 and 16 you used prompt = "Choose a lower number: " (and "higher" in line 16 accordingly) - how can one just put a variable and have its value printed out ? don't you have to use the print() method for that ?
You will learn much faster if you poke around inside programs to learn how they work.
Oct-31-2022, 09:09 AM
Over two years ago, you got a reply from ndc85430, that covered this exact topic (https://python-forum.io/thread-25302.html)
Maybe you should go back and check what you've posted and what answers you got, that way you can learn from what others have taken the time and trouble to post.
You can also learn a good deal of the basics (as well as more advanced topics) from the likes of https://www.w3schools.com/python/, among others.
Maybe you should go back and check what you've posted and what answers you got, that way you can learn from what others have taken the time and trouble to post.
You can also learn a good deal of the basics (as well as more advanced topics) from the likes of https://www.w3schools.com/python/, among others.
Oct-31-2022, 01:25 PM
rob101 - i think that in the thread you directed me to - the question was different, and the code there is obviously much more simpler and less well written...
deanhystad - thank you for the answer, i have PyCharm Community, but i don't know exactly what to do - do i simply put on the red dot on the left side and run the debug, i really haven't tried before what you suggest
i really am not trying to get easy answers, sometimes i just don't know, but i look up in different websites to find answers, it's only when i haven't found an answer elsewhere is when i ask here for clarifications...
deanhystad - thank you for the answer, i have PyCharm Community, but i don't know exactly what to do - do i simply put on the red dot on the left side and run the debug, i really haven't tried before what you suggest
i really am not trying to get easy answers, sometimes i just don't know, but i look up in different websites to find answers, it's only when i haven't found an answer elsewhere is when i ask here for clarifications...
Oct-31-2022, 02:28 PM
If you validate the user input, you don't need to raise an exception.
Some input is easy to validate; this is one such case: a integer number between 1 and 10.
Some input is easy to validate; this is one such case: a integer number between 1 and 10.
def check_input(n): """check the user input for a valid number. if valid, return the number, otherwise return 'None'""" for number in n: if number.isnumeric(): pass else: return None return int(n) user_input = "" while not user_input: user_input = check_input(input("Pick a number between 1 to 10: ")) if user_input not in range(1, 11): print("Out of range.") user_input = ""
Oct-31-2022, 04:11 PM
ok rob101 thank you, this helps me much, thank you !
Pages: 1 2