+ 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

8th Sep 2017, 8:31 AM
Kevin
Kevin - avatar
1 Respuesta
+ 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' ;)
8th Sep 2017, 8:44 AM
visph
visph - avatar