Python multidimension problem

aim:Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j.
Note: i=0,1…, X-1; j=0,1,¡­Y-1.
Example
Suppose the following inputs are given to the program:
3,5
Then, the output of the program should be:
[[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]

l=[""]
r=input("enter the no. of rows")
c=input("enter the no. of coloumns")
x=int(r)
y=int(c)
for i in range(0,x):
    for j in range(0,y):
        l[i][j]=i*j
print(l)

pls help me out… there is an error at line 8
l[int(i)][int(j)]=i*j
TypeError: ‘str’ object does not support item assignment

You get this error because of this:

You are initializing your list with a string.
Get rid of those quotes from your list and try again.

Hope this helps.

Just as the error message says, you can’t modify a string.

One approach, which will let you keep most of the code you’ve written, is to convert your string to a list of characters:

str = list(str)

Then join it back into a sting when you’re done:

str = "".join(str)