0

29.9 Practice - Where’s my seat - Python

Can anyone get test cases 2, 3 and 4 to work. Here is my code that works for test case 1 but not the others. Thanks. seats = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'] ] print(seats[1][1])

23rd Mar 2021, 7:07 PM
Zach Z
9 ответов
+ 2
Your code will always output 'e' as the seat, because you hard coded the indices.
23rd Mar 2021, 7:24 PM
ChaoticDawg
ChaoticDawg - avatar
+ 2
thanks ChaoticDawg im not sure what to do instead?
24th Mar 2021, 12:28 AM
Zach Z
+ 2
Zach Z I would need a description of the problem, because I do not have a pro subscription. The object for the challenges is to take into consideration the inputs, what should happen with them to get the desired output given any edge cases etc. Not just solve for particular outputs, but to give the correct output in the correct format for the given input regardless of what that input may be (within the limitations of the description of the challenge). Try to think it through and solve the challenge yourself first. Then if you continue to have issues. Give a description of the issue and what you have tried so far. Save your current code for the challenge in the SoloLearn playground and provide a link to it, so we can help you further.
24th Mar 2021, 12:57 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
got it!! thank you ChaoticDawg & Scott-Russell Clark
26th Mar 2021, 1:37 AM
Zach Z
0
you will most likely have to loop through the inputs. something like.... N = inputs() for x, y in N.split(“ “): print(seats[x][y])
23rd Mar 2021, 8:05 PM
you are smart. you are brave.
you are smart. you are brave. - avatar
0
Try using input(), and have a read of the instructions. For example: row = int(input()) I hope this helps
24th Mar 2021, 7:07 PM
Scott-Russell Clark
Scott-Russell Clark - avatar
0
Try this one, works for me: (Here r stands for row and c for columns.) seats = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'] ] r = int(input()) c = int(input()) print(seats[r][c])
27th Mar 2021, 5:17 PM
Alex B
Alex B - avatar
0
This one works too seats = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'] ] #your code goes here x = int(input()) y = int(input()) c = (seats[x][y]) print (c)
24th Jul 2021, 12:57 PM
For_the_love_of_coding
For_the_love_of_coding - avatar
0
that code isnt working ugh
22nd Oct 2021, 3:23 AM
Mahib Mehta
Mahib Mehta - avatar