String Indexing
String Indexing
machine = "Computer"
# C - 0 -8
# o - 1 -7
# m - 2 -6
# p - 3 -5
# u - 4 -4
# t - 5 -3
# e - 6 -2
# r - 7 -1
print(machine[-1]) #prints the last character of string
print(machine[0]) #prints the first character of string
Post a Comment