I am trying to make a Python program that will choose a random number from the user's input, and it gives me this error ValueError: invalid literal for int() with base 10: ' 5 , 10'
when I write random number from 5 to 10
I tried to delete spaces but it doesn't help, here is my code:
import random
from random import randrange
useless = ['random number from', 'random number', 'from']
to = ['to']
a = ["'"]
s = input('?')
if 'random number' in s:
for u in useless:
s = s.replace(u,'')
for to in to:
s = s.replace(to,', ')
for a in a:
s = s.replace(a,'')
print(s)
print(randrange(int(s)))
Aucun commentaire:
Enregistrer un commentaire