-1

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))

1
  • 1
    There is no difference as you see. Both are string formatting options, with f-strings being newly introduced. Commented Aug 15, 2020 at 9:57

2 Answers 2

2

Effectively both do the same thing. The f you mention is an f-string which is available from python 3.6

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.