Ticker

6/recent/ticker-posts

Python Strings | Let's Update

 Python Strings


Python Strings | Let's Update


Strings are in python surrounded by either single quotation, double quotation or tirple quotation.

Example:

print("Let's Update")

print('Let's Update')

The Above Two Lines Are Also Give the Same Meaning.


How can assign the string to variable?

Python also allows as to store strings in variables by using a common declaration statement.

Example:

a="Let's Update"

print=(a)


Multiline Strings

Python also Allows As to assign a multiline string to a variable by using triple quotes;

Example:

a="""This Website Teach You an All required Programming Skills Like,

python,C++,C#,C,JAVA"""


Strings Are Arrays

Like many other popular programming languages, Python also supports, array the string by using its Unicode characters.

Square brackets can be used to access elements of the string.

Example:

a="Hello, Welcome to Let's Update"

print(a[1])

                                                                    Output:

                                                                            e


Looping Through a String

Example;

for x in "hello":

       print(x)

                                                                  Output:

                                                                        h

                                                                        e

                                                                         l

                                                                         l

                                                                         o


String Length

To find Length of the string By using len() function;

Example:

     a="hello"

     print(len(a))


Check If It Is Exist

To check if a certain phrase or character is present in a string by using keyword in;

Example:

  a="hai, Hello."

  print("hai" in a)
                                                      Output:

                                                            True


Post a Comment

1 Comments

  1. The History of the Casino - One of the Most Popular Casinos
    A relative newcomer septcasino.com to kadangpintar the world of online gambling, Wynn Las ventureberg.com/ Vegas opened its doors to a new audience of over 600,000 in 2017. This was the first casinosites.one casino

    ReplyDelete