
Patrick B. answered 03/11/21
Math and computer tutor/teacher
######################################
def reverseStr(Str):
revStr = " "
nLength = len(Str)
for i in range(nLength-1,-1,-1):
chChar = Str[i]
revStr = revStr + chChar
return revStr.strip()
###########################################
def printStrBackwards( str):
print(reverseStr(str))
########################################
data = "myprogram.exe"
print(data[2]) #the output is the character 'p', the 3rd character
print(data[-1]) #the output is the character 'e' the last character
nLength = len(data)
print(len(data)) #length of the string is 13
print(data[0:8]) # the output is "myprogra"
# starts at index zero, then the next 8 characters
print(data[2:5]) # starts at index 2, then the next 3 characters
print(data[5:9]) #starts at index 5, then the next 4 characters
print(data[10:13])
print("middle char is " + data[nLength//2])
printStrBackwards(data)