Computer Science, asked by adarshsrekanthpbulaa, 5 months ago

(WILL MARK BRAINLIEST IF YOU ANSWER PROPERLY)

Write a program that asks the user to enter a string. The program should then print the following:
a. The total number of characters in the string
b. The string repeated 10 times
c. The first character of the string (remember that string indices start at 0)
d. The first three characters of the string
e. The last three characters of the string
f. The string backwards
g. The string with its first and last characters removed
h. The string in all caps
i. The string with every a replaced with an e
j. The string with every letter replaced by a space

1

Answers

Answered by jai696
11

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

s = input("enter string: ")

print(f"total chars: {len(s)}")

print(f"repeat 10x: {s * 10}")

print(f"first char: {s[0]}")

print(f"first 3 chars: {s[:3]}")

print(f"last 3 chars: {s[-3:]}")

print(f"reversed string: {s[::-1]}")

print(f"1st & last char removed: {s[1:len(s) - 1]}")

print(f"string in caps: {s.upper()}")

print(f"replace a with e: {s.replace('a', 'e')}")

# replacing every letter with space

replace_letters_space = [" " if s.isalpha() else s for s in list(s)]

print(f"replace letter with space: {''.join(replace_letters_space)}")

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions