+ 9

Lists

The seats in your ticketing program are stored in a 2D list. Each seat is assigned a letter code. Complete the program to take the seat row and column as input and output the corresponding code from the list (row and column indices start from 0). Sample Input 3 2 Sample Output k Note, that you need to convert the input() to int, in order to use it as an index.

11th Apr 2021, 6:06 AM
Veena Tirmal
Veena Tirmal - avatar
17 Answers
+ 3
So, you have to take two inputs. First input = row Second input = column Then, use int() on both input to convert them to integers. Then you can get the output. Output = list [row] [column] This is the logic you should follow. row = int(input()) column = int(input()) print(seats[row][column])
11th Apr 2021, 6:17 AM
CHANDAN ROY
CHANDAN ROY - avatar
+ 6
Guess the output of this code: things = [”text", 0, [1, 2, 8], 4.56] print(things[2][2]) answer 8
5th Feb 2022, 5:23 PM
Badal Kushwaha
+ 3
It's very simple, just try this: seats = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'] ] row = int(input()) column = int(input()) print(seats[row][column])
2nd May 2021, 4:46 PM
Alok Jha
Alok Jha - avatar
+ 2
Veena Tirmal It's okay. Don't get discouraged. Try to understand the problem. Indexing is a way to access the elements from a list. As it's not good to post complete solution here, I have sent solution in DM with explanation.
11th Apr 2021, 6:23 AM
CHANDAN ROY
CHANDAN ROY - avatar
+ 2
Chandan Roy wrote, "Well, you can find this here. Courses[Python for beginners][Lists][29.2] Trying to find it in Python core will give an index error " Response: Ok. It is "Where's my Seat" in the Python for Beginners in the Lists section. It is a Pro-only practice question so I didn't do that yet. Veena wrote, "This is from python core" which is why I searched the Python Core course earlier.
11th Apr 2021, 6:42 AM
Josh Greig
Josh Greig - avatar
+ 1
The sample output should be ‘L’ not ‘ K’. Let’s not forget the first row starts from zero aswell as the first column and K is the 3rd row and 2nd column meaning [3][1]
22nd May 2021, 11:22 PM
Nana King Obedson
Nana King Obedson - avatar
+ 1
answer : 8
21st Nov 2021, 10:03 AM
Rawad Altaib
0
Can you share your attempt? Is that from Python?
11th Apr 2021, 6:11 AM
Josh Greig
Josh Greig - avatar
0
This is from python core, I tried different concepts maybe I'm too weak at this Josh Greig CHANDAN ROY
11th Apr 2021, 6:20 AM
Veena Tirmal
Veena Tirmal - avatar
0
Did anyone else get an Syntax Error stating the print function is invalid although your code is correct? This is in reference to the seat challenge.
24th Dec 2021, 5:01 AM
Dimagio Burnside
Dimagio Burnside - avatar
12th Feb 2022, 10:22 AM
Apdirahman Mohamed Mohamud
Apdirahman Mohamed Mohamud - avatar
0
its ans is 8
13th Jan 2023, 1:56 PM
Engr.Ayesha Liaqat
Engr.Ayesha Liaqat - avatar
- 1
seats = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'] ] When I'm starting to solve, I'm given this Josh Greig CHANDAN ROY
11th Apr 2021, 6:22 AM
Veena Tirmal
Veena Tirmal - avatar
- 1
I completed the Python Core course and can't find that question but I have an attempt below. One thing that makes little sense to me about that question is the 3, 2 inputs leading to 'k' and how they also say the indexes start at 0. The 3 is understandable but the 'k' is at index 1 from its containing list which means that if 2 corresponds with that index, it must be 1-based instead of 0-based. I used that assumption in the code below: seats = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'] ] n = int(input()) m = int(input()) print(seats[n][m - 1]) The above code will print k for inputs: 3 2 I'm just not sure it is right given the apparent contradiction in requirements.
11th Apr 2021, 6:32 AM
Josh Greig
Josh Greig - avatar
- 1
Well, you can find this here. Courses[Python for beginners][Lists][29.2] Trying to find it in Python core will give an index error
11th Apr 2021, 6:38 AM
CHANDAN ROY
CHANDAN ROY - avatar
- 1
seats = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'], ['j', 'k', 'l'] ] row = int(input()) column = int(input()) print(seats[row][column])
14th Aug 2021, 2:58 PM
Vraj Soni
Vraj Soni - avatar
- 4
could you help me with this Guess the output of this code: things = [”text", 0, [1, 2, 8], 4.56] print(things[2][2])
19th Sep 2021, 5:21 PM
Raghul Manoharan
Raghul Manoharan - avatar