0

Hi! Please provide errors and solutions for the code. Also, what to do when two lists have the same value?

P.S. Can this be also done using dictionaries? If possible please let me know. Also, I have just started learning python. So please be kind enough to answer in a simple language. Thanks a tonne in advance. Here's the code- gryffindor=0 slytherin=0 hufflepuff=0 ravenclaw=0 user=input('how do you describe yourself-cunning/daring/loyal/sharp?') if user=='cunning': slytherin+=1 elif user=='daring': gryffindor+=1 elif user=='loyal': hufflepuff+=1 elif user=='sharp': ravenclaw+=1 last=input('What\'d you do in a difficult faceoff-face enemy/negotiate/fight enemy/wait?') if last=='face enemy': hufflepuff+=1 elif last=='negotiate': slytherin+=1 elif last=='fight enemy': gryffindor+=1 elif last=='wait': ravenclaw+=1 final=int(input('please press 1 ro see the result:')) sort=[gryffindor,slytherin,hufflepuff,ravenclaw] i=0 while i<=3: if final==1: print(max(sort)) else: print('the value entered is invalid kindly enter again') i+=1

13th Oct 2021, 2:13 PM
Himanshu Priyadarshi
Himanshu Priyadarshi - avatar
2 Answers
+ 1
Can you please explain what exactly you are trying to do..? To get it easy
13th Oct 2021, 3:12 PM
Indira
Indira - avatar
0
Yeah Actually I was trying to create a program that acts like the sorting hat from Harry Potter that sorts people based on their personality aspects. My aim was to take user inputs and add them to the list with house names. In the end I tried to print the list with maximum value
14th Oct 2021, 7:56 AM
Himanshu Priyadarshi
Himanshu Priyadarshi - avatar