Helpme on the sololearn challenge about New Driver License | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Helpme on the sololearn challenge about New Driver License

i have my code here, and it works on 2nd 3rd and 5th case , but not the rest, please kinda fix this myname = input() agent = int(input()) other = list(input().split()) other.append(myname) other.sort() people = len(other) process = people/agent + .5 process = int(round(process)) time = 0 for i in range(0,people,process): if myname in other[i:i+process]: time += 20 break else : time += 20 print(time)

6th Jan 2023, 3:31 PM
Farrel Baskara
Farrel Baskara - avatar
2 Answers
+ 2
Hi Farrel Baskara The first part of your code seems correct. Not sure what the `process` is meant to represent though. I'm guessing it's a stepping value of some sort, since you have it in the for loop. If that's the case, then you don't need to calculate it - you can just use `agent`. So if I understand your loop logic correctly, it'll work if you just use `agent` in place of `process`. You can also just use one update of `time` in the beginning of the loop, since it executes in both case of the if-else. Like this: for i in range(0, people, agent): time += 20 if myname in other[i:i+agent]: break Hope this helps.
6th Jan 2023, 5:18 PM
Mozzy
Mozzy - avatar
0
thankyou so much! helps a lot
7th Jan 2023, 1:25 PM
Farrel Baskara
Farrel Baskara - avatar