

Even regular Rust code is more “exciting” than Python in this regard, since you have a choice between self
, &self
, and &mut self
. And occasionally mut self
, &'a self
, and even self: Box<Self>
. All of which offer different semantics depending on what exactly you’re trying to do.
Nice! Some feedback (on your Python, I don’t speak Greek):
snake_case
– for example,greekTranslation
should begreek_translation
. (EDIT after seeing your most recent reply: good luck with that when it comes to Python :) )reverseTranslation
every time the user requests an English-to-Greek translation. Unless you’re planning to modifygreekTranslation
while the program is running, it would likely be more efficient to makereverseTranslation
a global variable, computed just once at the start of the program.while optionSelection == <'practice'/'translation'>
makes it look likeoptionSelection
could change to something else inside the loop, yet you never do so. You could just writewhile True
instead.else
branch to the mainif
-elif
-elif
chain. That way, if you added in a new option, you would only have one place in the code to modify instead of two. (Also, instead ofx != a and x != b and x != c
, you could writex not in [a, b, c]
).if
-elif
-elif
chain, you could replace it with amatch
statement, which would remove the repetitions ofoptionSelection ==
.Here’s how I would write the control flow for the last section:
optionSelection = input().strip().lower() match optionSelection: case 'practice': while True: practiceGreek() print('') print('Would you like another? [yes] [no]') print('') selection = input().strip().lower() print('') if selection != 'yes': break case 'translate': while True: translateToGreek() print('') print('Would you like to translate another phrase? [yes] [no]') print('') selection = input().strip().lower() print('') if selection != 'yes': break case 'exit': print('') print('Thank you for using the Greek Practice Program!') print('') sys.exit() case _: print('') print('Please select either practice, translate, or exit') print('')
(You could probably pull the
while True
loops into their own dedicated functions, actually.)Hope that helps. Feel free to ask if any of this doesn’t make sense.