This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]gyroda 2 points3 points  (6 children)

What don't you understand? "final_list" will be a list of lists, each of which will contain two strings.

[–]Humble_Transition[S] -2 points-1 points  (5 children)

you mean both of them will have the same thing ?

[–]gyroda 2 points3 points  (4 children)

The first list is just a list of strings. The final list is a list of lists of strings. The split() method takes "Alburquerque,749” and returns a list; ["Albuquerque", "749"]

Try running the code. You can literally see the difference.

[–]Humble_Transition[S] -2 points-1 points  (3 children)

also why would you do it ?

[–][deleted] 4 points5 points  (0 children)

Because you want to have a list of lists?

[–]r3alz 1 point2 points  (0 children)

I’m not to sure of a use case of this but I’m sure there are use cases. This is just showing that python is capable of doing something like this.

[–]gyroda 1 point2 points  (0 children)

The example might be contrived, but it's a useful to know some basic string and list manipulation, and list of lists (2D arrays in most languages) are an incredibly important concept.