Possible Duplicate:
Python decimal range() step value
I have a cycle in C:
for (float i = 0; i < 2 * CONST; i += 0.01) {
// ... do something
}
I need the same cycle in python, but:
for x in xxx
not the same.
How can i make it in python?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are almost on the line. This is how you do it on a list: –
If you want to iterate over a certain range: –
To give a step value you can use a third parameter, so in your case it would be: –
But you can only give an
integervalue as step value.If you want to use
floatincrement, you would have to modify your range a little bit:-