String snippets

22 Sep 2022

append character to string

with + operator

s = "Hell"
c = "o"

full_string = s + c

using the join() method

s = "Hell"
c = "o"
res = "".join((s, c))

check if character is alphabetical

ch = 'a'

if(ch.isalpha()):
    print(f"{ch} is alphabetical")
else:
    print(f"{ch} is NOT alphabetical")

links

social