separate words and lowcase it in python

To separate words and make them lowercase in Python, you can use the split() method to break a string into a list of words, then use lower() method to convert each word to lowercase. Finally, you can join the words back together using the join() method.

Here's an example:

main.py
# input string
my_string = "Hello World! How ARE you?"

# split into words and lowercase them
words = my_string.lower().split()

# join words back into a string
lowercase_string = " ".join(words)

# output lowercase string
print(lowercase_string)

# Output:
# hello world! how are you?
286 chars
15 lines

In this example, we first call lower() function on my_string to make all the letters lowercase. We then call split() on the result, to break the string into a list of words. We cast the resulting list of words into lowercase and then join them back together into a lowercase string using a space as a separator with join(). Finally, we print the resulting lowercase string.

gistlibby LogSnag