How to get the first word in a string Python?

Today, We want to share with you python get first word in string.In this post we will show you string split, hear for how to extract a word from a string we will give you demo and example for implement.In this post, we will learn about How To Check If String Contains Substring In PHP? with an example.

get first word in string python

Method #1: Using split()

Get first word in string

string = "Welcomes Pakainfo"
results = string.split()
first_word= results[0]
print(first_word)

Output:

Welcomes

Get the All words in a string

Example

string = "Welcomes Pakainfo is the easy Free Application Development Welcomes Guyes"
results = string.split()
print(results)

Output:

['Welcomes', 'Pakainfo', 'is', 'the', 'easy', 'Free', 'Application', 'Development', 'Welcomes', 'Guyes']

I hope you get an idea about python get second word in string.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment