0

Guys , please tell me what's the mistake and the correct code .

Task Given everyone's name that showed up at the same time, determine how long it will take to get your new license. Input Format Your input will be a string of your name, then an integer of the number of available agents, and lastly a string of the other four names separated by spaces. Output Format You will output an integer of the number of minutes that it will take to get your license. Sample Input 'Eric' 2 'Adam Caroline Rebecca Frank' Sample Output 40 CODE : name=input() agent=abs(int(input ())) x=input() others=x.split() others.append(name) others.sort() sno=others.index(name) time=20 if agent>=sno: print('20') elif agent<sno: for i in range (0,sno,agent): time+=20 print(time) else: pass

23rd May 2021, 4:06 PM
Swain
6 Respuestas
+ 3
you have just to swap th equal sign from if to elif statements, and it's better to explicitly initializing the 'time' variable to zero: if agent>sno: print('20') elif agent<=sno: time = 0 for i in range (0,sno+1,agent): time+=20 print(time) else: pass however, you doesn't need the elif: if agent>sno: print('20') else: time = 0 for i in range (0,sno+1,agent): time+=20 print(time)
23rd May 2021, 5:34 PM
visph
visph - avatar
+ 3
Suvashis Swain , please give us some more details what the problem is. ▪︎describe the input data, the resulting data and what the expected output is. thanks!
23rd May 2021, 4:44 PM
Lothar
Lothar - avatar
+ 2
visph thanks bro , ahhhh it was a silly mistake sno takes index no. and I took it as in whole no. i.e. index+1 😂
23rd May 2021, 5:57 PM
Swain
+ 1
where is your code attempt
23rd May 2021, 4:09 PM
Matias
Matias - avatar
0
There's the code.
23rd May 2021, 4:13 PM
Swain
0
Lothar , Eg : Inputs respectively, 'Eric' 2 'Adam Caroline Rebecca Frank' Output: 40 (means it will take 40 mins for Erik to get his license). Explanation It will take 40 minutes to get his license because he is in the second group of two to be seen by one of the two available agents.
23rd May 2021, 5:01 PM
Swain