Python Strings
Output
Hallo World
Example
x="Hallo World!"
print(x[0])
print=(x[-1])
print=(x[1:4])
print=(x[-3:-1])
print(x[0])
print=(x[-1])
print=(x[1:4])
print=(x[-3:-1])
Try it Yourself »
Output
H
!
all
ld
!
all
ld
- upper : string output in capital ccharacter
- lower : string output in small characters
- remove whitespace : remove space from string
- replace : replace a characters in string
- format : insert numerical value in string
- split : string convert into list
- center : output string from center
- count : count input character
- endswith : check last string
- index : get spacific character index number
- isalnum : check alfa-numerical numbers in string
- isdigit : check digit in string
- isidentifier : check identifier in string
- islower :check string characters is lower
- isprinttable : check string is printable or not
- isspace : check space in string
- istitle : check it is title
- isupper : check is upper
- join : add two strings
Example
x="This is python string"
y=2022
z=year
print(x)
print(x.upper())
print(x.lower())
print(x.strip())
print(x.split(","))
print(x.replace("is","are"))
print(x.format(y))
print(x.center(40))
print(x.endswith("string"))
print(x.index("is"))
print(x.isalnum())
print(x.isdigit())
print(x.isidentifier())
print(x.islower())
print(x.isprintable())
print(x.isspace())
print(x.istitle())
print(x.isupper())
print(x.join(z))
y=2022
z=year
print(x)
print(x.upper())
print(x.lower())
print(x.strip())
print(x.split(","))
print(x.replace("is","are"))
print(x.format(y))
print(x.center(40))
print(x.endswith("string"))
print(x.index("is"))
print(x.isalnum())
print(x.isdigit())
print(x.isidentifier())
print(x.islower())
print(x.isprintable())
print(x.isspace())
print(x.istitle())
print(x.isupper())
print(x.join(z))
Try it Yourself »
Output
This is python string
THIS IS PYTHON STRING
this is python string
this is python string
['this is python string']
this is python string
True
2
False
False
False
True
True
False
False
False
ythis is python stringethis is python stringathis is python stringr
THIS IS PYTHON STRING
this is python string
this is python string
['this is python string']
this is python string
True
2
False
False
False
True
True
False
False
False
ythis is python stringethis is python stringathis is python stringr
No comments:
Post a Comment
Tell us how you like it.