I try to run the code:
for c in range(10, 21):
print(c)
print([c[1]])
And I get the error: TypeError: 'int' object is not callable Why? How can I pick a specific element from an integer?
I try to run the code:
for c in range(10, 21):
print(c)
print([c[1]])
And I get the error: TypeError: 'int' object is not callable Why? How can I pick a specific element from an integer?
result = [i for i in range(10,21)]
for c in result:
print(c)
print(result[1])
#what you are trying is illegal in python. Int 'int' object is not subscribable. #Only lists or tuples, set, string... are subscriptable.
you are iterating in an iterable, you need to declare before the list to access to the element something like this:
a = range(10,21)
for i in a:
print(i)
print(a[1])
In your code every iteration the value of c are: 10 11 12 13 ... This is the reason of you error