+ 1

What does this mean?

What does split() method mean? I can't understand wheb do I use this.

15th Feb 2021, 1:20 PM
ekkwnsnsnwkkqwknnq
ekkwnsnsnwkkqwknnq - avatar
2 Antworten
+ 6
It's awesome, used on a string of characters, it "splits" or seperates words into a list. By default, it splits at spaces. so: sent = "hello there world".split() print(sent) #output ["hello", "there", "world"] But also you can split on any character. Say you have ip addresses. "10.10.0.30" ip = "10.10.0.30".split('.') print(ip) #output ["10", "10", "0", "30"] best for chopping up data to make it easier to manage and change
15th Feb 2021, 1:28 PM
Slick
Slick - avatar
+ 5
It used to convert a string to list which is based on the argument u gave in the split I.e( it will drop the element on the string then split to list) Eg ```py "BRuhBoy".split("B") # it drops B and convert to list like ["Ruh","oy"] ```
15th Feb 2021, 1:28 PM
Ananiya Jemberu
Ananiya Jemberu - avatar