Answer the question
In order to leave comments, you need to log in
Works not the if which should, what's wrong?
I made a generator in which the user can choose the interval, everything seems to work
import random
a = input("Введите ОТ скольки рандомизировать: ")
b = input("Введите ДО скольки рандомизировать: ")
c = random.randint(int(a), int(b))
print (c)
import random
a = input("Введите ОТ скольки рандомизировать: ")
b = input("Введите ДО скольки рандомизировать: ")
if b > a:
c = random.randint(int(a), int(b))
else:
c = random.randint(int(b), int(a))
print ('Правильный порядок ОТ и ДО, а не ДО и ОТ как сделали вы! Но число всё равно сгенерировано')
print (c)
Traceback (most recent call last):
File "main.py", line 7, in <module>
c = random.randint(int(a), int(b))
File "/usr/lib/python3.4/random.py", line 218, in randint
return self.randrange(a, b+1)
File "/usr/lib/python3.4/random.py", line 196, in randrange
raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
ValueError: empty range for randrange() (100,8, -92)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question