- 1

Why i got spaces between the letters and numbers

file = open("/usercode/files/books.txt", "r") cont=file.readlines() file.close() book_1title=(cont[0]) print(cont[0][0],len(book_1title.strip())) book2_title=(cont[1]) print(cont[1][0],len(book2_title.strip())) book_3title=(cont[2]) print(cont[2][0],len(book_3title.strip())) book_4title=(cont[3]) print(cont[3][0],len(book_4title.strip())) Heres a photo of the output https://www.linkpicture.com/q/Screenshot_20210929-171350.jpg

29th Sep 2021, 2:13 PM
עמנואל מחשבים
5 Antworten
+ 1
"Image not found" But when you separate two things in a print statement with a comma python inserts a space. So the output of print("Image", "not", "found") is Image not found
29th Sep 2021, 2:23 PM
Simon Sauter
Simon Sauter - avatar
+ 1
You can override this default behaviour with the sep option.
29th Sep 2021, 2:26 PM
Simon Sauter
Simon Sauter - avatar
29th Sep 2021, 2:43 PM
Simon Sauter
Simon Sauter - avatar
0
Ok i understand now Thank you very much 😀
29th Sep 2021, 2:25 PM
עמנואל מחשבים
0
Like this? book_4title=(cont[3]) print(cont[3][0],len(book_4title.strip()sep=""))
29th Sep 2021, 2:40 PM
עמנואל מחשבים