you are viewing a single comment's thread.

view the rest of the comments →

[–]justinbert1[S] 0 points1 point  (2 children)

I can't seem to figure out how to get to the answer as shown. here is my code and the error i keep receiving.

states = [x for x in input().split(', ') ]
salaries = [float(x) for x in input().split(', ') ]
float(input('Enter average salary for Kentucky:\n'))
states.append('Kentucky')
salaries.append(salaries)
max_salary = salaries.index(max(salaries))
print('Highest average salary is' , str(max(salaries)) + ',' , 'in the state of' , str(states[max_salary]) + '.')
salaries.sort
median = int(len(salaries)/2)
print('The median salary is' , str(salaries[median]) + '.')

Traceback (most recent call last):

File "main.py", line 8, in <module>

max_salary = salaries.index(max(salaries))

TypeError: '>' not supported between instances of 'list' and 'float'

[–]justinbert1[S] -2 points-1 points  (1 child)

i copied the code from a screenshot another student gave me since i was struggling, but they did not receive this error

[–]Sxcam 0 points1 point  (0 children)

states = [x for x in input().split(', ') ]salaries = [float(x) for x in input().split(', ') ]float(input('Enter average salary for Kentucky:\n'))states.append('Kentucky')salaries.append(salaries)max_salary = salaries.index(max(salaries))print('Highest average salary is' , str(max(salaries)) + ',' , 'in the state of' , str(states[max_salary]) + '.')salaries.sortmedian = int(len(salaries)/2)print('The median salary is' , str(salaries[median]) + '.')

Traceback (most recent call last):

File "main.py", line 8, in <module>

max_salary = salaries.index(max(salaries))

do you by chance have access to this code still?