0

please explain this code how it's work

file = open("/usercode/files/books.txt", "r") for title in file: for word in title.split(): print(word[0], end="") print() #your code goes here file.close()

18th Aug 2022, 2:23 PM
Sojib Mia
Sojib Mia - avatar
5 odpowiedzi
18th Aug 2022, 3:21 PM
Sojib Mia
Sojib Mia - avatar
+ 7
Sojib M , just to add one comment to the post of Jayakrishna🇮🇳 : ... print(word[0], end="") # print only the first character 'word[0]' of each splited word, but print them all in the same line ...
18th Aug 2022, 3:05 PM
Lothar
Lothar - avatar
+ 3
file = open("/usercode/files/books.txt", "r") # open file in read mode.. for title in file: # for each line from file for word in title.split(): # split by space, each line into words print(word[0], end="") # print the split words first (edit:) character only, with in same line. print() # print line break #your code goes here file.close() # close opened file # hope it helps.....
18th Aug 2022, 2:43 PM
Jayakrishna 🇮🇳
+ 1
Oh. I have a typo mistake in 'first, it's not for'. [ first character only . not for character only ]
18th Aug 2022, 3:11 PM
Jayakrishna 🇮🇳
+ 1
its printing the first character of each word in the title.. For example..."Here is the title" gives "Hitt".
20th Aug 2022, 4:59 AM
Jamari McFarlane
Jamari McFarlane - avatar