Python F-string Formatting

This topic is to discuss the following lesson:

Hello,

kindly, this code doesn’t work could you check:

vendor = "CiScO"
print(f"Router is from vendor: {vendor.title()}.")

Hello @ahmedamrici ,

This is working for me:

>>> vendor = "CiScO"
>>> print(f"Router is from vendor: {vendor.title()}.")
Router is from vendor: Cisco.

On Python 3.8.6. title is a string method.

Rene

1 Like

Thanks dear I had below error, I did correct it
AttributeError: ‘str’ object has no attribute ‘litle’. Did you mean: ‘title’?

but why don’t you show the print output in the lessons ?

We use trinket for lessons so it’s interactive:

For local testing, it’s best to use vscode.

1 Like

Hello Ahmedlmad

Using the Trinket applet, you can see the output in the pane on the right in the lessons. For the particular code you mentioned, I get this:


You can see the output on the right. You can also display the console output by clicking the “Console” option as shown below:

Does that make sense?

I hope this has been helpful!

Laz

1 Like

yes

Yes thanks guys appreciate your help.

1 Like