0

I need the system or friends to check the key

I solved the last quiz for the python developing course and the answer is coming as per the needed result still it is not giving me that ia ok or does not give me a fault in the code what should I do to get out of this quiz the code with open("/usercode/files/books.txt") as f: line_count = 0 for lines in f: word = 1 for i in lines: if i == ' ': word +=1 numbs=str(line_count+1)+': '+str(word) print(' Line',numbs,'words ') print() line_count+=1 f.close()

13th Feb 2024, 11:28 AM
mahmud kamal
2 Answers
+ 1
mahmud kamal , Some things I see. # This should all be on the same # line, and ' Line' should be 'Line ' # and 'words' should be ' words'. print(' Line',numbs,'words ') # Is it required to have a blank # line after each output? print() # When you use the with keyword, # the file is closed automatically, # so remove this. f.close() Have you learned f-strings yet? They make it a lot easier to print a mix of text and variables. https://www.pythontutorial.net/JUMP_LINK__&&__python__&&__JUMP_LINK-basics/python-f-strings/
13th Feb 2024, 12:34 PM
Rain
Rain - avatar
+ 1
mahmud kamal , Please add a python tag to this discussion.
13th Feb 2024, 12:48 PM
Rain
Rain - avatar