H
H
Herben2021-09-07 08:07:18
Python
Herben, 2021-09-07 08:07:18

How to randomize a number using input?

I tried to make a randomizer in which you can enter numbers through input

import random

a = input("От скольки: ")
b = input("До скольки: ")
c = random.randint(a, b)
print(c)


But I get an error about how I understood after many attempts that the values ​​cannot be randomized

Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "/usr/lib/python3.8/random.py", line 248, in randint
    return self.randrange(a, b+1)
TypeError: can only concatenate str (not "int") to str


How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sand, 2021-09-07
@Herben

c = random.randint(int(a), int(b))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question