Suppose that we have a record from file for the Student class defined earlier and we need to parse it.
Here is the example that do the parsing:
record_to_parse = "dmitri,telinov:python,nodejs,c++"
line = record_to_parse.split(":")
first_name, last_name = line[0].split(",")
courses = line[1].split(",")
print(first_name, last_name, courses)
Output:
dmitri telinov ['python', 'nodejs', 'c++']
The split() method splits a string into a list.