Question: Error in Python Code When Using Random.randint ( ) The below is my code. I am trying to set the arguments in Random.randint ( )
Error in Python Code When Using Random.randint
The below is my code. I am trying to set the arguments in Random.randint as the inputs upper bound and lower bound. However, I am getting the error in the picture.
# Guessing Game
# main.py
import random
import math
# Taking Inputs for lower & upper bounds of the range and number of guesses
lowerbound input Enter Lower Bound:
upperbound input Enter Upper Bound:
nGuesses input Enter Maximum Number of Guesses:
# Generating random number between the lower and upper
x random.randintlowerbound, upperbound
printYou have only nGuesses, chances to guess the integer between lowerbound, "and upperbound
# Initializing the number of guesses.
count
while count nGuesses:
count
# taking guessing number as input
guess input Enter a number:
# Condition testing of the guess
if guess x:
print You guessed too small!"
if guess x:
print You guessed too high!"
# If Guessing is more than required number of guesses, shows this output.
if count nGuesses:
print
The number is d x
printtBetter Luck Next time!"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
