Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Syntax

Escaping

# It will occure errror
>>> 'This is Bya's pen.'
  File "<input>", line 1
    'This is Bya's pen.'
                 ^
SyntaxError: invalid syntax
# Double quotation is smart
>>> "This is Bya's pen."
"This is Bya's pen."

# Using escape syntax : '\'
>>> 'This is Bya\'s pen.'
"This is Bya's pen."

Escape characters:

  • ' single quote
  • " double quote
  • \t tab
  • \n new line(Line break)
  • \ Backslash

Raw string

This is Bya\'s pen.
>>> r'This is Bya\'s pen.'
"This is Bya\\'s pen."
>>> print(r'This is Bya\'s pen.')
This is Bya\'s pen.

Multi Line

>>> """Hey
... this is test.
... You got it ?"""
'Hey\nthis is test.\nYou got it ?'

As list

>>> var = "Hello, Bya"
>>> var
'Hello, Bya'
>>> 'Hello' in var
True
>>> 'hello' in var
False
>>> var[1:5]
'ello'
>>>

String Methods

upper(), lower(), isupper(), islower()

>>> var = "Hello, Bya"
>>> var.upper()
'HELLO, BYA'
>>> var
'Hello, Bya'
>>> var = var.upper()
>>> var
'HELLO, BYA'
>>> var.lower()
'hello, bya'
>>> var.isupper()
True
>>> var.islower()
False

other methods:

  • isaplha(): letters only
  • isalnum(): letters and numbers only
  • isdecimal(): numbers only
  • isspace(): whitespace only
  • istitle(): titlecase only