i'm learning python from a book that i bought in 2017 and from a online course at the same time.
The book says that i should format the string like this example;
print("Guess number %d of %d" % (variable1, variable2))
But the online course says that i should format this way;
print("Guess number {} of {}".format(variable1, variable2))
Which one should i use for today programming standards?
Well, from Python 3.6, you can use f-strings:
print(f"Guess number {variable1} of {variable2}")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With