fill in the blanks to open a file, read its content and print its 2nd line | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

fill in the blanks to open a file, read its content and print its 2nd line

file=open("filename.txt", "r") cont=file. () print(cont[]) file.close

17th Oct 2023, 1:47 AM
Jannah Mae Ynion
Jannah Mae Ynion - avatar
1 Réponse
+ 5
file = open("filename.txt", "r") cont = file.readlines() print(cont[1]) # Index 1 corresponds to the second line (indexing starts at 0) file.close() Let me know if this helped!
17th Oct 2023, 2:06 AM
xJAYOx
xJAYOx - avatar