+ 1
Safety deposit boxes
#yet another broken piece of code def steal(items, item): time=0 items=[].split(",") for index in items: if items[index]==item: return 5 else: time+=5 return time print(steal(int(input()), int(input())))
10 ответов
+ 6
Trey ,
there are several issues to solve:
> input is requested to be 2 strings, but your input tries to create int values, which will raise an exception. (input / output samples from the task description are still missing)
> split() is not correctly done.
> the logic in the for loop is not completely correct.
+ 2
You are robbing a bank, but you’re not taking everything. You are looking for a specific item in the safety deposit boxes and you are going to drill into each one in order to find your item. Once you find your item you can make your escape, but how long will it take you to get to that item?
Task
Determine the amount of time it will take you to find the item you are looking for if it takes you 5 minutes to drill into each box.
+ 2
Also, please save your code in the playground and post a link here. Those of us who want to help don't need/want the extra work of parsing your code out of your post.
but i'll give you props for already commenting out the non-code!
+ 2
Instance of “list” has no “split” member
+ 1
Lothar mentioned something incorrect about the .split(), your code is giving you an error because of that .split()
So let's look at that line:
items = [].split(",")
what are you wanting to do with this line of code?
+ 1
It is nice to see someone try to use functional programming principle, although it is not required in this challenge.
Set the split() method aside as Aaron Lee & Lothar already mentioned, you have a miss understanding about list indexing.
In the lines below
for index in items:
if items[index] == item:
What is the value of index is holding? What value are you expecting?
There are other issues too, but you can fix some of them from our hints, and try to look at the error message and debug the code yourself.
0
what error are you getting?
0
So what lines need to be changed?