Wednesday, June 22, 2022

Python - Concatenate strings

a = "Hello, World!"

# Prints HELLO, WORLD!
print(a.upper())

# Prints hello, world!
print(a.lower())

print("---")


a = "   Hello, World!   "
# Prints "Hello, World!"
# Notice the space at the beginning and end is removed (stripped)
print(a.strip())

print("---")
print("Destructive?")

# Destructive to original contents?
a.strip()

# No.  Not destructive.  This will print the original with spacing intact
print (a)

# So we gotta do this?
a = a.strip()
print (a)

print("Split examples:")
# This will return a list
b = a.split(",")
print (b)
# Told you it was a list
print (type(b))
print ("Type: " + str(type(b)))