Python 3 Script to Convert Strings to List Array Using Split() Method

Python 3 Script to Convert Strings to List Array Using Split() Method

Python 3 Script to Convert Strings to List Array Using Split() Method

# Python code to convert string to list

def Convert(string):
    li = list(string.split(" "))
    return li

# Driver code   
str1 = "Geeks for Geeks"
print(Convert(str1))
# Python code to convert string to list
def Convert(string):
    li = list(string.split("-"))
    return li
  
# Driver code    
str1 = "Geeks-for-Geeks"
print(Convert(str1))
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment