0
What this i++ and why basically we wrote this on loops?
please read the title😁 thx for the support guys
4 odpowiedzi
+ 4
There is no ++ operand in python. Use i += 1 instead. It's the same as i = i+1. And you don't need this while looping, there are better ways in python:
for elem in mylist:
elem += 1
for index, value in enumerate(mylist): #if you need to operate with indexes
mylist[index] = value + 1
0
It is increment operation. By default it increments the value by 1. i++ if used in a function or print, it will print the value first and then set it to i+1. Whereas ++i means increase the value first then print it or use it or pass it.
Warning python doesnt use this convention. Python equivalent is i+= 1
0
ohh ok guys thank you so much 😊
0
i++ is used for increment, Python doesn't use this kind of convention ( or should i say, Python has another way of doing this kind of operation ) Python's equivalent to i++ incrementation is i+=1