![]() |
Warning: integer argument expected, got float
i'm getting the following error when trying to divide by numbers inside of a list. I'm a little new to Python, and i was wondering how i can fix this problem.
sphere.py:23: Deprecation Warning: integer argument expected, got float for y in range(notch[x] / 360): Code:
import math |
notch[x] is not guaranteed to be an integer. You may want to do:
int(round(notch[x]))Edit: It is not guaranteed to be an integer because you are assigning it a value that makes use of r, which is a float. Range requires an integer to generate a number from 0 to that number-1. |
Quote:
The problem is that 360 will always be divided by a float, and i need to store the result in a resultant list somewhere for later manipulation..... how exactly do i do that? Or...should i use a different kind of loop structure? |
Well again
int(round(notch[x])). It doesn't assign the rounded number, it just converts it for usage. |
notch[x]/360 is likely going to be a float anyway, regardless of whether notch[x] were rounded. And the problem is, range simply doesn't want floats; hence, the Deprecation Warning.
I believe "a different kind of loop structure" is truly in order. |
Quote:
i think it's ok, learning any new language has it's ins and outs. i'm learning them as i go. |
| All times are GMT +1. The time now is 03:48 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.