Why is there TypeError in line 2? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is there TypeError in line 2?

import random value = list(random.randint(1,6)) print(value) Error is:- Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not iterable

8th Jun 2019, 5:34 PM
Neeraj Kumar Arya
Neeraj Kumar Arya - avatar
1 Answer
+ 4
You are trying to create a list out of a number (in this case a random one), and that doesn't work. You can only make a list out of iterables, like other lists, tuples, strings etc.
8th Jun 2019, 5:38 PM
HonFu
HonFu - avatar