-
Notifications
You must be signed in to change notification settings - Fork 0
/
translate.py
29 lines (25 loc) · 915 Bytes
/
translate.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
# Author : Salim Suprayogi
# Ref : freeCodeCamp.org ( youtube )
def translate(phrase):
"mengganti huruf tertentu"
translation = ""
# loop
for letter in phrase:
# cek apakah ada huruf AEIOUaeiou
# jika ada ganti dengan huruf "g"
if letter.lower() in "aeiou":
# ubah phrase menjadi huruf kecil
if letter.isupper():
# cek, apakah phrase huruf kapital
# jika iya, ganti dengan "G" kapital
translation = translation + "G"
else:
# jika bukan huruf kapital
# ganti dengan "g" kecil
translation = translation + "g"
else:
# jika tidak ada huruf AEIOUaeiou, tampilkan phrase
translation = translation + letter
return translation
if __name__ == "__main__":
print(translate(input("Enter a phrase: ")))