+ 2

What's wrong with this code?

ss=int(input("Enter the number of secret codes:")) for i in range(ss): sn=input("Enter the name of code:") nos=int(input("Enter number of codenames:")) print("Enter the details of the codes in the following format:Codename,Code1|Code2:") d2 = dict(input().split('|') for i in range(nos)) print(d2) key_list = list(d2.keys()) val_list = list(d2.values()) val_list = [int(i) for i in val_list] maxm = val_list[0] for x in val_list: if x > max : max = x # print key with val position = val_list.index(x) print("The code2 with the highest value obtained as per the given details:",x) print("The details of the code in",sn,"is:") pin=key_list[position].split(",") print("Codename:",pin[0]) print("Code1:",pin[1]) It doesn't work when I put values like: rrf,99|87 ggo,101|76 It doesn't print the maximum value i.e rrf but prints ggo instead. Is there anything wrong with this code? Please let me know

28th May 2021, 5:02 PM
MsBonnie
MsBonnie - avatar
2 Antworten
+ 6
MsBonnie , what we are missing is a proper and complete task description. what is your code going to do? thanks!
28th May 2021, 7:05 PM
Lothar
Lothar - avatar
+ 1
It's going to print the maximum value of code 2, along with the respective details like codenames and code 1
29th May 2021, 3:42 AM
MsBonnie
MsBonnie - avatar