stamps = set()
for _ in range(int(raw_input())):
print 'underscore is', _
stamps.add(raw_input().strip())
print stamps
:
how_many_loops = int(raw_input())
stamps = set()
for i in range(how_many_loops):
print 'loop count is', i
stamps.add(raw_input().strip())
print stamps
Because everything that you enter in range()must be calculated before the start of the cycle, so the first one is int(raw_input())requested only once. If you use something like for i in range(very_expensive_list)this, it will take a long time, then start the loop.
source
share