In this program, the newlines are removed from all the lines in a list.

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

This actually strips whitespace (newlines and spaces) from the front and back of the string.

cloudfox
Автор

only if it's in the front or back. Use
replace('/n', '') to remove all positions

quadee
Автор

You are underrated. I enjoy all of your vids

stephenowesney
Автор

s.strip() removes spaces and newlines from the both sides of the string. You can use s.rstrip('\n') to remove only newlines from right side of the string (from the end)

complexairport
Автор

You can use the map function as well for this
data=list(map(lambda x:x.strip(), data))

RahulKumar-pjwb
Автор

Wowww...just incredible n awesome how u made this so simple

softcoda
Автор

Very useful especially for beginners like me. Thanks sir.

junealexissantos
Автор

Your videos help me learn Python, thank you! Subscribed

norb
Автор

Put a newline in the middle of the string and it will not work.
str.strip() removes all white spaces ONLY from the start and end of the string.
str.replace("\n", "") would be better.

monochromeart
Автор

I would have probably created some overly complicated for: loop and used two lists instead of just kinda recursively editing the existing one

locust
Автор

Can anybody tell me tune name ya song name plz

shivamrock
Автор

Bro make video on user input with spilt and strip ... We cannot understand that please make video on that

vineeth_reddy_s