top of page

Python Strings

A string is a sequence of characters. You can loop through the characters in a string, unlike an integer or real number

​

Splitting Strings

​

Lets play around with the word "Hawaiin"

​

pizza="Hawaiin"

​

print(pizza[0]) .....will get you >>>>>   H

print(pizza[:5]) ....will get you >>>>>   Hawai
print(pizza[0:2]) ..will get you >>>>>   Ha
print(pizza[6]) .....will get you >>>>>   n
print(pizza) ..........will get you >>>>>   Hawaiin
print(pizza[2:4]) ...will get you >>>>>   wa
print(pizza[3:]) .....will get you >>>>>   aiin

​

Joing Or Concatenating Strings

​

name="Ellizabeth"

greeting="Hello"

​

print(greeting + name)     .....will get you >>>>>  ​HelloElizabeth
print("Hi", name)  .................will get you >>>>>   Hi Elizabeth
print(name," ",name)    ........will get you >>>>>   Elizabeth   Elizabeth  
print(name * 2)   ...................will get you >>>>>   
ElizabethElizabeth
print(greeting,"",name[1:4])  will get you >>>>>   Hello  liz

​

​


 


​

​

Slide1.JPG
Slide3.JPG
Slide2.JPG
Slide4.JPG
bottom of page