+ 1
Python List Need Help!
I just randomly made this and I was wondering why I was receiving: Type error: argument of type int is not iterable Here's my code: https://code.sololearn.com/cA9I0fx5V589/?ref=app Please help! Thanks
1 ответ
+ 4
When you write:
if x in a:
You are testing if x is item of the list a.
If you want to test equality with a particular item, you need to write:
if x == a[i]:
or even 'if x is a[i]'
... but when you write:
if x in a[i]:
this will work only if item a[i] is also a list (or more generally an iterable, ie: a list-like object).
In your case, your list only contain numbers, which are not 'iterable' ;)