this question has answer here:
- how can read inputs integers? 14 answers
ok making python random number generator parameters defined user. writing on python 3.4. code:
import random import time name = input("whats name? ") numofnums = input("ok " + name + " how many numbers want randomize? ") def randomgenerator(): randomfinal = random.randint(1, numofnums) print (randomfinal) rerun = input("do want pick random number? ") if rerun == "yes": time.sleep(0.05) randomgenerator() else: print("you may close windows") randomgenerator() i having issue line:
randomfinal = random.randint(1, numofnums) i cannot use variable 'numofnums' parameter. have ideas?
make integer int():
import random import time name = input("whats name? ") numofnums = int(input("ok " + name + " how many numbers want randomize? ")) def randomgenerator(): randomfinal = random.randint(1, numofnums) print (randomfinal) rerun = input("do want pick random number? ") if rerun == "yes": time.sleep(0.05) randomgenerator() else: print("you may close windows") randomgenerator()
Comments
Post a Comment