Reputation: 4170
I have a list like this:
['0', '2757', '2757']
When I run this:
for i in results[1]:
print i
it's return 4 lines
2
7
5
7
I only want it to return the number 2757
Upvotes: 0
Views: 994
Reputation: 1
This loop is specific to the second value in the list so i represents each character of the element in this loop. You can just print the second item of the list
>>> list = ['0', '2757', '2757']
>>> print list[1]
2757
or if you want to run a loop that returns each item you have to make it non specific to the second item in the list
>>> for i in list:
... print i
0
2757
2757
Upvotes: 0
Reputation: 76194
Assuming by "return" you mean "print". You don't need a loop. Just print the element directly.
>>> seq = ['0', '2757', '2757']
>>> print seq[1]
2757
Upvotes: 2