Python ShortCut : Print In A Line



Print something  in a line within a for loop is a HECK thing for python beginners. So, i tried this and it worked..

Example: 

for i in range(5):
   print(i)

Output : 
0
1
2
3
4

But if we add  another argument (namely " end=' ' ") in print() then it gives us desired output.
Lets see:

for i in range(5):
   print(i, end=' ')

Output:
0 1 2 3 4



Enjoy Coding

Comments