+ 8
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.
19 Answers
+ 4
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])
+ 9
Guess the output of this code:
things = [”text", 0, [1, 2, 8], 4.56]
print(things[2][2])
answer 8
+ 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])
+ 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.
+ 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.
+ 1
Can you share your attempt? Is that from Python?
+ 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]
+ 1
answer :
8
0
This is from python core, I tried different concepts maybe I'm too weak at this Josh Greig CHANDAN ROY
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.
0
its ans is
8
0
Introduction to python in solo learn list practice problem answers
0
How to next next practice
- 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
- 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.
- 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
- 1
seats = [
['a', 'b', 'c'],
['d', 'e', 'f'],
['g', 'h', 'i'],
['j', 'k', 'l']
]
row = int(input())
column = int(input())
print(seats[row][column])
- 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])