Python Forum
I don't know if it's my error or Python error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I don't know if it's my error or Python error
#5
import random
from random import randint


x = [random.randint(1,100)]

print("Guess a number between 1 and 100.")

while True:
	guess = int ( input("a numer: ") )
	if str(guess) == str(x):
		print("Congratulations!")
	elif str(guess) < str(1) or str(guess) > str(100):
		print("You have to choose a number between 1 and 100.")
		print("Please guess again.")
	elif str(guess) < str(x):
		print("Please choose a higher number.")
	elif str(guess) > str(x):
		print("Please choose a smaller number.")
Reply


Messages In This Thread
RE: I don't know if it's my error or Python error - by SkitzGerald - Nov-25-2017, 03:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on first Python launch garryp4 5 347 May-07-2024, 03:56 PM
Last Post: deanhystad
  QGIS 3.34 Python Error paskiller 2 764 Nov-13-2023, 06:20 PM
Last Post: buran
  Python error on mentioned Arduino port name dghosal 5 915 Aug-22-2023, 04:54 PM
Last Post: deanhystad
  Code error from Fundamentals of Python Programming van Richard L. Halterman Heidi 12 1,818 Jul-25-2023, 10:32 PM
Last Post: Skaperen
Thumbs Down Python Error MahendraYadav 0 360 Jul-21-2023, 05:07 PM
Last Post: MahendraYadav
  Syntax error while executing the Python code in Linux DivAsh 8 1,783 Jul-19-2023, 06:27 PM
Last Post: Lahearle
Sad "PriceSystem" Python Script error to Shopify API Alphetto 0 464 Jul-04-2023, 10:03 AM
Last Post: Alphetto
  Error when running kivy on python janeik 8 2,172 Jun-16-2023, 10:58 PM
Last Post: janeik
  error python audio codiac 3 4,292 Mar-30-2023, 03:12 PM
Last Post: deanhystad
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,641 Mar-27-2023, 07:38 AM
Last Post: buran

Forum Jump:

User Panel Messages

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