0

I'm trying to calculate something in a function with numbers from an imported list.

def calculate_powers(velocities_list):
 power_list = []
 for i in velocities_list:
 power = 8/27 * 1.225 * i * 8659
 power_list.append(power)
 print(power_list)

However, I get the following error:

File "C:\Users\Omistaja\PycharmProjects7円_1\wind_turbine.py", line 6, in calculate_powers
 power = 8/27 * 1.225 * i * 8659
TypeError: can't multiply sequence by non-int of type 'float'

What to do?

asked Nov 9, 2021 at 10:39
3

2 Answers 2

1

try this :

def calculate_powers(velocities_list):
 power_list = []
 for i in velocities_list:
 power = float(8/27) * 1.225 * float(i) * float(8659)
 power_list.append(power)
 print(power_list)
answered Nov 9, 2021 at 10:43
Sign up to request clarification or add additional context in comments.

Comments

1

your variable 'i' is probably string, you need to cenvert it to number(float or int,..)

power = 8/27 * 1.225 * float(i) * 8659

can you provide example of your velocities_list?

answered Nov 9, 2021 at 10:48

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.