-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbroken_keyboard_vowel.py
More file actions
59 lines (46 loc) · 1.28 KB
/
broken_keyboard_vowel.py
File metadata and controls
59 lines (46 loc) · 1.28 KB
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
56
57
58
59
"""The broken keyboard toggles the case of letters every time a vowel is pressed.
def type_with_broken_keyboard(word):
So, the case changes every time a vowel is encountered.
Return the string as typed by the keyboard.
Note: Assume that the keyboard starts from lowercase.
Example
input:'banana
output:bANanA
Reason: The word 'banana' starts with a lowercase. The first "A" toggles it to uppercase,
the second 'A' toggles it to lowercase and the final A toggles it to uppercase again.
The keyboard types 'bANanA'.
Input:'mississippi'
Output:mISSissIPPi
Input:'oooooooo'
Output:OoOoOoOo
"""
def type_with_broken_keyboard(word):
new=''
v = 'aeiou'
word = word.lower()
v_count=0
for char in word:
if char in v:
v_count+=1
if v_count%2==0:
new =new+char.lower()
else:
new =new+char.upper()
return new
word = input("Enter a Word : ")
print(type_with_broken_keyboard(word))
"""
___________FOR case change on only vowels__________
def type_with_broken_keyboard(word):
new=''
v='aeiou'
word=word.lower()
for char in word:
if char in v:
new = new+char.upper()
else:
new=new+char
return new
word=input("Enter a Word : ")
print(type_with_broken_keyboard(word))
"""