strings in python

String manipulation in python is very easy…try this

Introduction

String manipulation: In this post, you will learn about the strings in python and let’s make today’s session an awesome one and also below is the video format of the post do check it out ????

Video:

What is string manipulation ❓

In the previous post, I have told what is a string. The string is nothing but ” ” or ‘ ‘ is the string and manipulating anything in between the string is called string manipulation.

So, let’s directly dive into examples

Some Examples in string manipulation ????

Example1:

In this example let’s see how to manipulate a string value

Suppose you wanted to print three hello world in a row you would enter this command

But use string manipulation you can print hello world in a row multiple times using a single command.

The result will be ????

So, this is a string manipulation

The \n moves the next Hello world to the new sentence and just go try with your IDE or online compilers

Example2:

Now, let’s see how to leave a gap between words. It’s pretty easy.

Now, just copy the above code and paste it into any compiler and check for the result

Example3:

Using + and string ” ” let’s leave spaces between the values to be printed

The result looks something like this ????????

Escape character I found useful

\’    Single Quote
\”    Double Quote
\n    New Line
\r    Carriage Return
\t    Tab
\b    Backspace
\f    Form Feed
\ooo  Octal Value
\xhh  Hex Value

String Format operator

%c   character
%s   string conversion via str() prior to formatting
%i   signed decimal integer
%d   signed decimal integer
%u   unsigned decimal integer
%o   octal integer
%x   hexadecimal integer (lowercase letters)
%X   hexadecimal integer (UPPERcase letters)
%e   exponential notation (with lowercase ‘e’)
%E   exponential notation (with UPPERcase ‘E’)
%f   floating-point real number
%g   the shorter of %f and %e
%G   the shorter of %f and %E

Conclusion

Finally, All the above codes are in the below link and just click and verify if you have any doubts, cheers ????????

https://replit.com/@techyrick/n-string-manipulation#main.py


Also Read: Hello world in python full tutorial

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions or brave browser to block ads. Please support us by disabling these ads blocker.Our website is made possible by displaying Ads hope you whitelist our site. We use very minimal Ads in our site

 

Scroll to Top