mardi 22 mars 2022

Why can't I print a random number from 1 to a variable?

I was making a python program where you type in an input, and it finds a random number from 1 to that input. It won't work for me for whatever reason.

I tried using something like this

import random
a = input('pick a number: ')
print(random.randint(1, a))
input("Press enter to exit")

but it won't work for me, because as soon as it starts to print it, cmd prompt just closes. does anyone know how to fix this?




Aucun commentaire:

Enregistrer un commentaire