Different result with strip(), why ? - Python
Hello, Hope everyone is doing well, I have a question concerning a code I'm writing, that's supposed to print from a file all the worders that have more than 20 characters when I don't use the strip() method it gives me more words and when I use it, it only prints 3 words, why? I'm a beginner with coding in general. Thanks in advance everyone. ----------- My code --------- : def test(): #My steps : #Open the file - DONE #Read the file - DONE #Go through each line of the file - DONE #Read the words line by line - DONE #Identify the words with more than 20 characters - DONE #print the words - DONE file = open("words.txt","r") for line in file : words = line.strip() # HERE !!!!! if len(words) > 20 : print(words): ---------- without strip() ------------ : counterdemonstration counterdemonstrations counterdemonstrators hyperaggressivenesses hypersensitivenesses microminiaturization microminiaturizations representativenesses ----- And with the strip() ------ : counterdemonstrations hyperaggressivenesses microminiaturizations