-
Notifications
You must be signed in to change notification settings - Fork 3
/
3.2.1.11Lab.py
56 lines (38 loc) · 1.61 KB
/
3.2.1.11Lab.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'''
stimated time
5-15 minutes
Level of difficulty
Easy
Objectives
Familiarize the student with:
using the continue statement in loops;
modifying and upgrading the existing code;
reflecting real-life situations in computer code.
Scenario
Your task here is even more special than before: you must redesign the (ugly) vowel eater from the previous lab (3.1.2.10) and create a better, upgraded (pretty) vowel eater! Write a program that uses:
a for loop;
the concept of conditional execution (if-elif-else)
the continue statement.
Your program must:
ask the user to enter a word;
use user_word = user_word.upper() to convert the word entered by the user to upper case; we'll talk about the so-called string methods and the upper() method very soon - don't worry;
use conditional execution and the continue statement to "eat" the following vowels A, E, I, O, U from the inputted word;
assign the uneaten letters to the word_without_vowels variable and print the variable to the screen.
Look at the code in the editor. We've created word_without_vowels and assigned an empty string to it. Use concatenation operation to ask Python to combine selected letters into a longer string during subsequent loop turns, and assign it to the word_without_vowels variable.
Test your program with the data we've provided for you.
Test data
Sample input: Gregory
Expected output:
GRGRY
Sample input: abstemious
Expected output:
BSTMS
'''
# solution
user_word = input("Enter a word: ").upper()
word_without_vowels = ""
for letter in user_word:
if letter in "AEIOU":
continue
word_without_vowels += letter
print(word_without_vowels)