Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

useful functions in python

# 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))
'''


def listToString(s):
    # initialize an empty string
    str1 = ""

    # traverse in the string
    for ele in s:
        str1 += ele +' '

        # return string
    return str1

'''

# Driver code    
s = ['Geeks', 'for', 'Geeks']
print(listToString(s))

'''
Source by www.datacamp.com #
 
PREVIOUS NEXT
Tagged: #functions #python
ADD COMMENT
Topic
Name
2+1 =