Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Absolute Beginner to Python
I am an absolute beginner to python. I am learning through CodeHS. I cannot figure what I'm doing wrong with a particular assignment. It's the Guess the Secret Number assignment. I feel like I've done everything the way the sample says to do it, but it won't work. Please HELP!

secret_number = 7

def make_check(user_number):
user_number=int(input("What is the secret number? (1-10) "))

while user_number == secret_number:
    user_number=int(input("What is the secret number? (1-10) "))
Do some testing. What happens at this statement

while user_number == secret_number:
Again, do some testing.
print(user_number, secret_number)
while user_number == secret_number:
    print("within while")
Again, do some testing and find out.
It would be very helpful if you explained what you want your code to do, and what exactly doesn't work as you expect it to. Without that, we can only give our best guess.

Function make_check() will only be called as long as user is guessing the number correctly. First time he guesses wrong, even if it is very first attempt, the script will end. You probably don't want such program logic, and in that case, just think of the order of how the operations are executed.
Also you pass user_number value to make_check(), but it is not used there.
I'm very sorry for not explaining better.
The program is supposed to print a check mark on screen if a person selects the secret number.
Otherwise, it should ask for input again. I cannot get the while loop to work properly. Thanks for the help.
Then the call to make_check should be after the loop, not in it. Also the while loop should go while they haven't guessed the correct answer. Currently it loops while they have guessed the correct answer.
Craig "Ichabod" O'Brien -
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Thanks so much for all the help! Finally got it working! Big Grin

Possibly Related Threads…
Thread Author Replies Views Last Post
  Absolute beginner am I missing something? kamren 7 475 Sep-25-2020, 05:32 AM
Last Post: buran
  chkFile with absolute paths JarredAwesome 7 398 Sep-21-2020, 03:51 AM
Last Post: bowlofred
  absolute imports between folders mikisDW 0 289 Aug-05-2020, 12:26 PM
Last Post: mikisDW
  I am an absolute newbie.Help me! feynarun 4 563 Apr-11-2020, 09:25 PM
Last Post: feynarun
  Absolute newbie asking for help with blinking LEDs misterfrickel 0 650 Mar-15-2019, 08:54 AM
Last Post: misterfrickel
  Absolute Beginner Python Question matchamochi7 5 1,481 Nov-02-2018, 12:09 PM
Last Post: wookie
  Problem with absolute path to file (Mr.Stickman Problems) SheeppOSU 3 2,458 Jun-26-2018, 10:05 AM
Last Post: Larz60+
  coding error from a script (absolute noob) fuchls 2 1,952 Jun-08-2018, 02:29 PM
Last Post: webrunner1981

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020