error during producing random integer in python -
i using python producing random in integer between 2 value user, code follows. getting error:
from random import * i1 = input('enter n1 :') i2 = input('enter n2 :') r = randint({0},{1}.format(i1,i2)) print r
here taking i1 , i2 user , want produce random integer between i1 , i2.
i getting error:
file "index.py", line 6 r = randint({0},{1}.format(i1,i2)) ^ syntaxerror: invalid syntax
you need add quotation marks/apostrophes make {0},{1}
string:
r = randint('{0},{1}'.format(i1,i2))
this pass string random integer function though. function expects 2 integers. need is:
r = randint(i1, i2)
Comments
Post a Comment