-
Notifications
You must be signed in to change notification settings - Fork 9
/
class_rovarspraket.py
40 lines (35 loc) · 1.27 KB
/
class_rovarspraket.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
# Rövarspråket translator
# This program convert a given word or a phrase in the Swedish language game: Rövarspråket
# Made by Alessandro Silvestri
class Rovarspraket:
# I init all the variables
def __init__(self) -> None:
self.txt = ''
self.vowels = ('a', 'e', 'i', 'o', 'u', ' ')
self.b = ''
def rovarspraket_translate(self, txt):
# text converter. It returns the converted text
for i in txt:
if i in self.vowels:
self.b += i
else:
self.b += i + 'o' + i
return self.b
def ask_user(self):
# Interface with the user, asking for the text
while True:
a = input('insert a phrase to translate in rovarspraket: > ')
print(self.rovarspraket_translate(a))
while True:
exit = input("do you want translate another one? > (y/n) ")
if exit.lower() == 'y':
self.b = ''
break
elif exit.lower() == 'n':
break
else:
print('wrong command')
if exit.lower() == 'n':
break
translator = Rovarspraket()
translator.ask_user()