I already have a lot of experience in Python, but recently I've seen some people using else
at the end of a while
or for
block. I was very curious and decided to test:
for i in range(2):
print(i)
else:
print("Something...")
Output:
0
1
Something...
Using or not else, the code will execute the same way, so what's the use of this?