50926/how-do-i-loop-backward-using-indices-in-python
I want to loop from 100 to 0, how do I do it?
for i in range (100,0) #this is not working
Hi,
You can make use of negative indices to start from back:
for i in range(100): k = 100 - i print(k)
Or You can use:
for i in reversed(range(101)): print(i)
Both will give same output that is 100 to 0
Operator ^ is a bitwise operator, which does "bitwise exclusive or". More: http://wiki.python.org/moin/BitwiseOperators The ...READ MORE
Hi, it is pretty simple, to be ...READ MORE
$ to match the end of the ...READ MORE
down voteacceptedFor windows: you could use winsound.SND_ASYNC to play them ...READ MORE
You can also use the random library's ...READ MORE
Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE
Enumerate() method adds a counter to an ...READ MORE
You can simply the built-in function in ...READ MORE
Reversing a list is a commonly used ...READ MORE
You can use sleep() method to sleep ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.