Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What can I do to fix this and make it run right?

+3 votes
asked Mar 8 by Joey (540 points)
num_rows = int(input())
num_cols = int(input())
row_num = 1
col_let = '?'
# Note 1: You will need to declare more variables
# Note 2: Place end=' ' at the end of your print statement to separate seats by spaces

''' Your solution goes here '''

while row_num <= num_rows:
    col_let = chr(ord('A'))
    while col_let <= num_cols:
        print('{}{}'.format(row_num,col_let))
        col_let = chr(ord(col_let) + 1)
    row_num += 1

print()

as you may have gathered this is homework but since the class ends today this is for my own personal curiosity. I believe I have narrowed down the issue to the (while col_let <= num_cols:) line of code but I'm not sure how to proceed with that information. Any suggestions?

1 Answer

0 votes
answered Mar 14 by Peter Minarik (55,660 points)
If you look at the output, it says

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    while col_let <= num_cols:
TypeError: '<=' not supported between instances of 'str' and 'int'

So the problem is that you're trying to compare a string (col_let) to an integral number (num_cols), which doesn't make much sense.

I'm not sure what the program is supposed to do. Maybe that would help clearing out what's going on. Also, the variable names are not too great (what does col_let mean?)
commented Mar 14 by Joey (540 points)
Given num_rows and num_cols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print a space after each seat.

Sample output with inputs: 2 3
1A 1B 1C 2A 2B 2C

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the given problem

num_rows = int(input())
num_cols = int(input())

# Note 1: You will need to declare more variables
# Note 2: Place end=' ' at the end of your print statement to separate seats by spaces

''' Your solution goes here '''

print()

^^^^^^^^^^^^^^^^^^^^^^^^^
This is the given code that cannot be changed

much apologies for the confusion.
col_let is column letter, just one of the variables that I used along side row_num or row number
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...