LoginSignup
0
0

More than 3 years have passed since last update.

Python解説を覚え書き 2 - Strings

Posted at

print("Giraffe\nAcademy") # new line
print("Giraffe\"Academy") # escape sequence
print("Giraffe\\Academy")

phrase = "Giraffe Academy"
print("\n\n" + phrase) # appending another strings is concatenation (+)

# function
print(phrase.lower())
print(phrase.upper())
print(phrase.isupper())

# function in combination
print(phrase.upper().isupper())

# length function
print(len(phrase))

# index of the character
print(phrase[0])

# passing a parameter
print(phrase.index("a"))
print(phrase.index("Acad"))

# In here I can actually give this two parameters so I can give this replace function two values that it can use.
print(phrase.replace("Giraffe", "Elephant"))

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0