def engine(current_money=10.0):
# Instruction
print(
f"""
---------------------------------------------------------------------------
| You start with ${current_money} |
| Each play costs 25 cents. |
| For each play, the slot machine will output a random three-digit number.|
| If have two similar numbers, you will earn 50 cents. |
| If have three similar numbers, you will earn $10. |
---------------------------------------------------------------------------
"""
)
If current_money = 10.0
it will print:
---------------------------------------------------------------------------
| You start with $10.0 |
| Each play costs 25 cents. |
| For each play, the slot machine will output a random three-digit number.|
| If have two similar numbers, you will earn 50 cents. |
| If have three similar numbers, you will earn $10. |
---------------------------------------------------------------------------
but with current_money = 9.0
it becomes:
---------------------------------------------------------------------------
| You start with $9.0 |
| Each play costs 25 cents. |
| For each play, the slot machine will output a random three-digit number.|
| If have two similar numbers, you will earn 50 cents. |
| If have three similar numbers, you will earn $10. |
---------------------------------------------------------------------------
It will lose a space character in second line. How can I prevent this behavior? I want to make a function to print the text above but the value in f string
depend on the length of value current_money
. Is there a way to freeze a string?. Thanks for your help.