How do i convert an f-string in python so that it can be printed by python version older than 3.6?
print(f"Player 1: {move1} Player 2: {move2}")
When I try to run this in Python (3.5.3) it gives me a syntax error.
print("Player 1: {move1} Player 2: {move2}".format(move1=move1, move2=move2))
will work in most recent versions of python. As will
print("Player 1: {} Player 2: {}".format(move1, move2))
and if you want to use the old formatting syntax that'll work in python2 as well:
print("Player 1: %s Player 2: %s" % (move1, move2))
print(f"Player 1: {move1} Player 2: {move2}").format is already there (which is for recent python versions).
print("Player 1: {move1} Player 2: {move2}".format(move1=move1, move2=move2))format()method of the built-instrclass, which will work in both current and past versions (upto the point when that feature was added anyway — which was in Python 2.6).