In the Learn section, it lists the following code:
for word in words:
if word[0] == ‘@’:
usernames.append(word)
what exactly is the ‘[0]’ doing in this code and why does it cause an error when I try to use it with integers in the exercise? do you only need it when searching a list for strings?
for height in heights:
if height[0] > 161:
can_ride_coaster.append(height)
[Traceback (most recent call last):
File “script.py”, line 5, in
if height[0] > 161:
TypeError: ‘int’ object is not subscriptable]
When I remove the [0] from height, it works fine.
Thanks