Issue
Mostly I work with Python 3. There can I write this:
print(f"The answer is {21 + 21}!")
Output:
The answer is 42!
But in Python 2, f-strings do not exist. So is the following the best way?
print("the answer is " + str(21 + 21) + "!")
Solution
Using format
:
print("the answer is {} !".format(21 + 21))
Answered By - VnC
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.