So i've tried the formats string methods in python but what are the differences between them? Which method is best for me?
example1:
name = 'Dash'
print(f'Hello {name}!')
example2:
name = 'Dash'
print('Hello {}!'.format(name))
So i've tried the formats string methods in python but what are the differences between them? Which method is best for me?
example1:
name = 'Dash'
print(f'Hello {name}!')
example2:
name = 'Dash'
print('Hello {}!'.format(name))
Effectively both do the same thing. The f you mention is an f-string which is available from python 3.6
Print f is just a newer and easier way of inserting a variable into a string. I think it came in in python 3.6 . Both do really the same thing