String in Python3 - Coders PlayGround

Learn to code and change the future!

Tuesday, 29 August 2017

String in Python3

Hello friends, lets learn about the string in Python3.

Concatenation in Python3 can be done using two different ways, 
 a) Using a '+' operator
 b) Using a ',' operator

Sample Program:
 
# This doesn't add space unless we add 
print ("Hello" + "there!")

# This adds space
print ("Hello","there!")

# string and integer
print ("Hi" + "5")

#if only 5 is written then error will be displayed
# we can also write

print ("hi",str(5))

'''
If you don’t want characters prefaced by \ to
be interpreted as special characters, you can use
raw strings by adding an r before the first quote

'''
# check out this will treat (\n)ew as newline
# To avoid that check the second condition
print ('\Desktop\python3\new')
print (r'\Desktop\python3\new')

print ("""
Name Div 
ABC A
Xyz B
""")
 
Output
PropellerAds