String In Python

String In Python

String Data Type in Python

  • String is the collection of alpha numeric data, special character etc in single or double quotations.
  • There are many built in method to perform operations on string,
  • like to convert any string to uppercase, lowercase, to check is digit? is number?, length of string, searching in string etc.
  • String is the immutable data type, that cannot be update or modify after creation


How To Create String

Examples:

str1 = “Rushikesh Jethure”

str2 = “238843” # numeric string

str3 = “Rushikesh123” # alpha numeric string

str3? =? “True” # Boolean string


Access String (Element)

We can access string element using different way

Example:

str = “Rushikesh jethure”

1) Using variable method

e.g? print(str)

2) Using array method

e.g print(str[index number])

3) Using slice method

e.g print(str[starting index, ending point])

4) Using for loop method

str = “Rushikesh jethure”

for i in str:

? print(i)


Iterate String Using For Loop

We can iterate string items using for loop to access any specific items or to check any specific item in a string at specific location (index number)

Iterate means, we can get items of sequence data type one by one.

Example:

str = “Rushikesh”

for i in str:

? print(i)

R

u

s

h

i

k

e

s

h

List Of String Methods in Python

capitalize()?

casefold()?

center()?

count()?

encode()?

endswith()?

expandtabs()?

find()?

format()?

format_map()?

index()

isalnum()?

isalpha()?

isascii()?

isdecimal()?

isdigit()?

isidentifier()?

islower()?

isnumeric()

isprintable()?

isspace()?

istitle()?

isupper()?

join()?

ljust()?

lower()?

lstrip()?

maketrans()?

partition()?

replace()

rfind()?

rindex()?

rjust()?

rpartition()?

rsplit()?

rstrip()?

split()?

splitlines()?

startswith()?

strip()?

swapcase()?

title()?

translate()?

upper()?

zfill()?

要查看或添加评论,请登录

Rushikesh J.的更多文章

  • Linux Operating System

    Linux Operating System

    Linux Operating System ======================= => Linux is a community based OS => Linux is free & Open Source => Linux…

  • Infrastructure

    Infrastructure

    ================= Infrastructure ================= Servers (Machines) Databases Storage Network Security Backup =>…

  • Application Architectural Patterns

    Application Architectural Patterns

    =================================== 1) Monolithic Architecture (Outdated) 2) Microservices Architecture (Trending)…

  • DevOps Introduction

    DevOps Introduction

    =============== What is DevOps =============== DevOps = Development + Operations => DevOps is a culture/process in IT…

    2 条评论
  • Try and Exception in Python

    Try and Exception in Python

    Exception is the error and is an event, which occur when program statements are executing. It disrupts the flow of…

  • Python Array With Examples

    Python Array With Examples

    Array in Python Array in Python Array is the collection of items having same data type with contiguous memory location.…

  • Python Date Object

    Python Date Object

    We can work with time and date with Python. There are two module in Python time and datetime that used to work with…

  • String Formatting WITH Problems and Solution

    String Formatting WITH Problems and Solution

    What is String Formatting? It is the way to insert custom string or variable in a text (string). Using string…

  • SET Different Methods With Examples

    SET Different Methods With Examples

    SET Method : add() Working: This method is used to add element to set. Syntax: set.

  • Python SET Comprehension With Examples

    Python SET Comprehension With Examples

    What is Comprehension? ?We create a sequence from a given sequence is called comprehension. ?Sequence means list…

社区洞察

其他会员也浏览了