-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15.py
32 lines (28 loc) · 1.04 KB
/
15.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#Write a Python program that will ask the user to enter a word as an input.
#If the length of the input string is less than 4, then your program should print the same string as an output.
#If the input string’s length is greater than 3, then your program should add "er" at the end of the input string.
#If the input string already ends with "er", then add "est" instead.
#If the input string already ends with "est", then your program should print the same input string as an output
x = input("Enter a word: ")
y = len(x)
z = ""
if y >3:
if x.endswith('est'):
z = x
elif x.endswith('er'):
z = x.replace('er','est')
else:
z = x + 'er'
else:
if y < 4:
z = x
print(z)
#next problem:
print('''Write a Python program that will ask the user to input a string (containing exactly one word).
Then your program should print subsequent substrings of the given string as shown in the examples below.''')
x = "DREAM"
for i in range(len(x)+1):
print(x[:i])
x = "DREAM"
for i in range(len(x)+1):
print(x[i:])