Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Andrew BoosHartig
Andrew BoosHartig
274 Points

is there a good reason for using .format VS an f string?

The way im understanding '.format' is that it opperates almost identically to using the %g approach. Is there a good reason for doing this instead of usinf the inline f string approach like ive done here for my solution?

name = input("What is your name? ")
answer = input(f"Hello, {name}! Do you understand while loops? (yes/no) ")

while answer.lower() != "yes":
    print(f"OK {name}, while loops in Python repeat as long as a certain Boolean condition is met.")
    answer = input("Do you understand while loops now? (yes/no) ")

print(f"Great, {name}! I'm pleased that you understand while loops now. That was getting repetitive.")