Python Forum
What was my mistake in this Python code (easy)?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What was my mistake in this Python code (easy)?
#5
(Nov-19-2019, 09:44 PM)jefsummers Wrote: Let's clean this up
Good,when first has started the clean up process can take it a step further Wink
4 space indentation,snake_case,remove a str and (),import first.
import random

min_guess = 1
max_guess = 6
# Ask the user for their name and their max_guess
name = input("What is your name? ")
print(f"Hi {name}!")
print(f"Enter a number between: {min_guess} and {max_guess}")
guess = int(input("What is your guess? "))

# Generate a random number and tell the user if they won or lost
secret_number = random.randint(min_guess, max_guess)
if guess == secret_number:
    print("Congratulations, you got it right!")
else:
    print(f"You lose - the number was {secret_number}")
print("Thank you for playing Guess the Number.")
Reply


Messages In This Thread
RE: What was my mistake in this Python code (easy)? - by snippsat - Nov-19-2019, 09:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Code problem - probably easy fix? colin_dent 5 927 Jun-30-2023, 01:55 PM
Last Post: deanhystad
  [Solved] Please, help me find a simple mistake AlekseyPython 2 1,763 Jun-17-2021, 12:20 PM
Last Post: AlekseyPython
  [split] Could you please clarify where i did mistake also how run without admin right Abubakkar 1 1,803 Jun-14-2021, 09:32 AM
Last Post: Larz60+
  creating simplex tableau pivot program easy or difficult for a beginner in Python? alex_0 2 2,605 Mar-31-2021, 03:39 AM
Last Post: Larz60+
  Problem with very easy code. janekk9002 1 1,820 Dec-10-2020, 12:57 PM
Last Post: buran
  Please help to me to find my mistake in code leonardin 2 1,863 Nov-29-2020, 04:17 PM
Last Post: Larz60+
  minor mistake in code for factorial spalisetty06 2 1,903 Aug-22-2020, 05:00 PM
Last Post: spalisetty06
  Simple mistake about for Nomatter 4 2,287 Jul-16-2020, 02:24 PM
Last Post: Nomatter
  Install Mistake jlerette5 1 1,914 Feb-18-2020, 12:19 AM
Last Post: jefsummers
  countdown script not working..plz help what is mistake randyjack 1 2,124 Oct-28-2019, 06:57 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

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