1

I am very new to programming and Python!

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

I am getting error:

Traceback (most recent call last):
  File "<pyshell#20>", line 1, in <module>
    for i in range(0.6):
TypeError: 'float' object cannot be interpreted as an integer

3 Answers 3

4

Range takes in two values, not a single float!

It should be

for i in range(0,6):
    print(i)

this would give you

0
1
2
3
4
5

or just range(6)

Sign up to request clarification or add additional context in comments.

Comments

3

You probably meant this:

for i in range(0,6):
    print(i)

You need to change period to comma. Also, you need to indent the print statement.

Comments

1

You probably mistyped, and meant to put a comma instead of a dot:

for n in range(0,6):
    print(n)

actually, the '0' in range() is not even needed, you can also do this, and it will print the same thing:

for n in range(6):
    print(n)

both would output:

0
1
2
3
4
5

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.