this code doesn't run as expected in Python3 when I do my data-analysing practice.
The typeerror is "TypeError: unsupported operand type(s) for /: 'dict_values' and 'int'".
How should I solve it?
import numpy as np
# Summarize the data about minutes spent in the classroom
total_minutes = total_minutes_by_account.values()
total_minutes = np.array(total_minutes)
print('Mean:', np.mean(total_minutes))
print('Standard deviation:', np.std(total_minutes))
print('Minimum:', np.min(total_minutes))
print('Maximum:', np.max(total_minutes))
total_minutes = total_minutes_by_account.values()
The variable total_minutes
will be of type dict_values
.
To turn it into a list you need to wrap it in a list
function like this:
total_minutes = list(total_minutes_by_account.values())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With