A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://holypython.com/intermediate-python-exercises/exercise-1-python-format-method/ below:

Improve your skills with Exercise 1: .format() method

Let’s check out some exercises that will help you understand .format() method better.

Exercise 1-a: Python format method of strings

Place a curly bracket "{}" in the appropriate place and fill inside .format()'s parenthesis so that "Hello!, Name" is printed.


Although it might look slightly weird in the beginning, .format() method is an extremely convenient method for string class objects.

The syntax is:
“{} {}”.format(value1, value2…)

As curly brackets get replaced with values inside the parenthesis.

str = "Hello!, {}".format(name)

Exercise 1-b: Format method to type a number

Using a string and .format() method print the number: 1 only.


Although it might look slightly weird in the beginning, .format() method is an extremely convenient method for string class objects.

The syntax is:
“{} {}”.format(value1, value2…)

As curly brackets get replaced with values inside the parenthesis.

*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.

Umut Sagir

Finance & Data Science Professional,
Founder of HolyPython


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4