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

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -