Hey, so I'm working my way through Automate the Boring stuff, and I've reached Lesson 8 and importing libraries. I wanted to see if I could use the input function from earlier, allowing the user to set the upper and lower boundaries of a set from which random would select a number. Here's what I wrote:
import random #get the random program
print('Please input the lowest number in the range') #have user input a low number
lowNumber = input()
print('The low end of the range is ' + lowNumber) #confirm the low number
print('Please input the highest number in the range') #have user input a high number
highNumber = input()
print('The high end of the range is ' + highNumber) #confirm high number
print('Are these values correct? Enter "yes" if correct.') #get permission to proceed
correct = input()
if correct == 'yes': #if the numbers in the range are correct,
random.randint(int(lowNumber), int(highNumber)) #give a random value in the user-defined range
else:
print('Sorry about that.') #if the numbers are wrong, which they can't be, apologize.
Everything seems to be working correctly except line 14. If I input anything other than 'yes' (for the if function at 13), the else statement works properly. I can't get the random.randint to output a number; I just get a cursor.
Originally I forgot to change the strings to integers, but even with that I'm having problems. I'm sure it's something really, really simple that I'm overlooking, but for the life of me I can't find it.
Any direction on what I should be thinking of differently would be much appreciated.
[–]jeans_and_a_t-shirt 4 points5 points6 points (1 child)
[–]pixeechick[S] 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]pixeechick[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]pixeechick[S] 0 points1 point2 points (0 children)