Hi, I am struggling to understand the difference in string formatting with python
Pay particular attention to the last lines of code
Take a look at this code:
import random player_name ='Gandalf' player_type ='Wizard' def roll(): number = random.randint(1,20) return number print('A troll attacks!') troll_roll = roll() player_roll = roll() **print('Player: %s Troll: %s'%(str(player_roll),str(troll_roll)))```**
What are the advantages to printing using the above type of string formatting, as opposed to something like
print('Player: ', player roll, ' Troll: ', troll_roll)
Especially if I convert the variables to strings ahead of time? I feel like the second example reads better. Which should I use ?