0
Can someone elaborate this code
file = open("/usercode/files/books.txt", "r") for line in file : print(line[0] + str(len(line.strip()))) file.close() Especially the line.strip part (Taken from python core module end question)
1 Réponse
+ 5
strip() is an inbuilt function in Python programming language that returns a copy of the string with both leading and trailing characters removed (based on the string argument passed).
src: https://www.geeksforgeeks.org/python-string-strip/
[CODE]
l = '@@lone@@@'
print(l.strip('@'))
# O/P: lone
r = ' cool '
print(r.strip())
# O/P: cool