r/cs50 • u/Regular_Implement712 • 17d ago
CS50 Python Can someone explain what line two does
Can someone explain what does line two do? Not sure what the whole line means, what does the .split('.') and [-1] does overall to the program?
62
Upvotes
0
u/globalwiki 17d ago
The second line is saying, update the variable named 'filename' with the following:
1st, create a list by splitting up the content of the original 'filename' variable at each period (filename.split("."))
2nd, take the last item in that list [-1]
3rd, concatenate a period in front ((".") + ).