+ 1
How can I make this more compact?
This code would definitely follow the "I love typing" style as you will see. Any ideas how I can bring the amount of lines down? Even I think this is pretty bad (I've learned a lot since I've written it so I know) https://code.sololearn.com/caeXrTEd10z8/?ref=app
5 Answers
+ 4
You have written the same code for all the currencies.
You should always try to not repeat yourself.
My example (the pure core):
https://code.sololearn.com/cqVxgd93H5MV/?ref=app
+ 1
Use more dictionaries, they will help with your decisioning and your variable selections, you can even store your functions in a dictionary as well
https://code.sololearn.com/cs9HQL5QIwGW/#py
https://code.sololearn.com/cq12Bd2tgatz/#py
https://code.sololearn.com/cqbZK7wU8zLQ/#py
+ 1
HonFu two questions:
Is there a reason to split the dictionaries between multiple lines? Is it for readability?
And what does the "f" in f"insert random string" mean? I know that "r"string"" means raw string, but I have never seen an F there
+ 1
Ville Nordström, yeah, I restructure the lines for better readability.
The f marks a format string that allows you to put expressions into {} and get them inserted into the string.
+ 1
Ohh, so you don't have to write the whole "format" in front of it, I see haha Thanks HonFu