Learn Python Episode #9: String Manipulation

preview_player
Показать описание

What are some of the fun and useful things that we can do with strings in Python? Go ahead and open up a either your IDE, terminal, or command prompt and follow along. I find that if you're simply told to do something you may not remember the procedure next time. However, if you actually perform that actions yourself, it is much more likely to stick. So, the first thing we are going to cover is concatenating strings. Concatenating is essentially gluing two things together. Below is an example of concatenating two strings together:

"Hello, " + "Nick"

As you can see, you concatenate two strings by using the "+" operator. You can also use the string function to convert an integer to a string like so:

"This costs" + str(6) + "dollars

You can also perform mathematical operations within the string function parameter.

"This costs" + str(6+5) + "dollars"

So, how do we do the opposite of concatenation? We can split strings by using the ":" operator.

"Hello:Nick"

This all may not seem very exciting, and you may or may see how this could be useful, but you will see later on why concatenating is useful when coding.

Рекомендации по теме
Комментарии
Автор

Just as a nitpick, in Python these [ ] are called "lists." In some other languages (like Java) they are called "arrays."

nolanoster
Автор

hii, i want print two names ex;"My name is i want chaitanya kumar has to be printed then what to do

avinashgudipudi
Автор

Hey man just found your channel do you know how to get your BIOS passwords ?

heyy
Автор

Gudd doing its impressive make it more easy nd than take it to advanve leval

adityagupta