0
Hello.. This code work properly but it's not beautiful.. Can someone rewrite and make it more reusable and more beautiful pls ?
4 Antworten
+ 1
Nahum Maurice Prepare to be amazed!!
0
Why not rewriting yourself? :)
You can store your menu in a Dictionary:
menu = {'fruit1': price, 'fruit2': price, ...}
for fruit in menu with iterate over fruits.
menu['fruit1] will return the price.
Your discount lines looks the same. Dont repeat your self!
Try to define a function to calculate discount.
def discount(fruit)
0
I haven't learned the dictionaries yet.. they are my next lesson..
0
Thanks for your advice Qwertiony ! 👍