Today we are learning about string operations.
Strings are by default indexed, for example txt="hello hello". print(txt[0]) will print h.
Index values are determined using a colon to specify the range, for example print(txt[1:10]) will print characters from 1 to 9. The actual printed range does not include 10.
Not only can we determine the range, but we can also determine the step size. For example, print(txt[::2]) will print hlo... If it is print(txt[::-1]), it will reverse the string and print "olleh olleh". This parameter cannot be 0.
split() function can process the string into an array using the function parameter.
Today's exercise is to let the user input multiple strings and create a new string by taking a part from each one.
print("STAR WARS NAME GENERATOR")
print()
t1 = input("enter your first name: ")
t2 = input("enter your last name: ")
t3 = input("enter your mum's maiden name: ")
t4 = input("enter the city where you were born: ")
print(f"Your Star wars name is {t1[0:4]}{t2[0:3]} {t3[0:3]}{t5[-3]}")