lundi 2 février 2015

Python : Help on Random Number Code

Here is my code for the random nuumber generator. User inputs largest and smallest number and gets random number.



import random
Smallest_Number = raw_input('Enter Smallest Number: ')
Largest_Number = raw_input('Enter Largest Number: ')
print random.randint(Smallest_Number,Largest_Number)


Here's the error in console



Traceback (most recent call last):
File "C:/Users/Matthew/Documents/python/Random Number.py", line 7, in <module>
print random.randint(Smallest_Number,Largest_Number)
File "C:\Python27\lib\random.py", line 242, in randint
return self.randrange(a, b+1)
TypeError: cannot concatenate 'str' and 'int' objects


What am I doing wrong? Help needed and appreciated!





Aucun commentaire:

Enregistrer un commentaire