Here's my problem.
I need a matrix (a list of lists) of undefined size (maybe I should define it as an empty list?). The matrix will have a size of nxm but n and m will be introduced by the user.
Now, the user will also introduce the values for the matrix as a string, for example: list[0]="Hello" but I need to store that string as a list of 5 elements list[0]=[H, e, l, l, o]
Is there a not so complicated way to do that?
So far what I'm thinking is to define an empty list list=[] and then to ask for the number of lines the matrix will have, then to change the size of list according to the value introduced (no idea on how to do that). Once the list has the desired size, I'd ask for each of the strings and convert it to list using list(string) (I know there's such a function, but not sure if it works on lists inside a list)...
well, that's my idea. Python is the very first programming language I try to learn and don't know how to write it properly, so forgive me if this is a super easy thing and I'm drawning in my own ignorance.
Thanks for any tips and sorry for the long post.
-RodAG
I need a matrix (a list of lists) of undefined size (maybe I should define it as an empty list?). The matrix will have a size of nxm but n and m will be introduced by the user.
Now, the user will also introduce the values for the matrix as a string, for example: list[0]="Hello" but I need to store that string as a list of 5 elements list[0]=[H, e, l, l, o]
Is there a not so complicated way to do that?
So far what I'm thinking is to define an empty list list=[] and then to ask for the number of lines the matrix will have, then to change the size of list according to the value introduced (no idea on how to do that). Once the list has the desired size, I'd ask for each of the strings and convert it to list using list(string) (I know there's such a function, but not sure if it works on lists inside a list)...
well, that's my idea. Python is the very first programming language I try to learn and don't know how to write it properly, so forgive me if this is a super easy thing and I'm drawning in my own ignorance.
Thanks for any tips and sorry for the long post.
-RodAG
Comment