Write a Python program that splits, doubles, and reverse each
input string entered. For each string,
split it at the given integer, and then output it in format as
shown below. Convert all stings entered to
uppercase for output. Assume string length is greater than the
split value. Refer to the sample output
below.
Sample Runs:
Enter a string: holiday
Enter the number to split on: 3
HOL-YADI-LOH-IDAY
Enter a string: TATTARRATTAT
Enter the number to split on: 6
TATTAR-TATTAR-RATTAT-RATTAT
Name the program: SDRXX.py, where XX are your initials
Python code:
#accepting string and converting it into uppercase
string=input("Enter a string: ").upper()
#accepting position to split
split=int(input("Enter the number to split on: "))
#spliting on the split position,[::-1] is used to reverse the
string
print(string[:split]+"-"+string[split:][::-1]+"-"+string[:split][::-1]+"-"+string[split:])
Screenshot:
Input and Output:
Get Answers For Free
Most questions answered within 1 hours.