+ 2
Can anyone explain how this code works?
file = open("/usercode/files/books.txt", "r") #your code goes here var = file.readlines() for name in var: l = list(name.split(' ')) s = "" for i in l: s += i[0] print(s) file.close()
1 Respuesta
+ 2
1. Iterates each line (each book title) of the file
2. Separates and Iterates each word of the book title
3. Get the first character of each word
4. Add those first character to 's'
5. Prints the 's'
Output:
---> Initials of each word each Book titles
Explanation inside 👇
https://code.sololearn.com/cED0N2c19xI9/?ref=app