Python Forum
Simple question about .format(* )
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple question about .format(* )
#2
formula is three element tuple. asterisk "unpack" the tuple into separate elements, thus providing the necessary number of arguments to .format()

Note you can use two asterisk ** to "unpack" mapping like dictionary
person = {'name':'John', 'age':17}
print('{name} is {age} years old'.format(**person))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Simple question about .format(* ) - by Motley_Cow - Oct-03-2019, 06:56 AM
RE: Simple question about .format(* ) - by buran - Oct-03-2019, 07:13 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Very Beginner question on simple variables Harvy 1 337 Apr-12-2024, 12:03 AM
Last Post: deanhystad
  Simple Question - ' defined as "a". ?' Ryan012 10 1,842 May-27-2023, 06:03 PM
Last Post: Ryan012
  Very simple question about filenames and backslashes! garynewport 4 2,128 Jan-17-2023, 05:02 AM
Last Post: deanhystad
  Python Tkinter Simple Multithreading Question AaronCatolico1 5 1,757 Dec-14-2022, 11:35 PM
Last Post: deanhystad
  A simple "If...Else" question from a beginner Serena2022 6 1,847 Jul-11-2022, 05:59 AM
Last Post: Serena2022
  Simple arithmetic question ebolisa 5 2,175 Dec-15-2021, 04:56 PM
Last Post: deanhystad
  Simple code question about lambda and tuples JasPyt 7 3,497 Oct-04-2021, 05:18 PM
Last Post: snippsat
Big Grin question about simple algorithm to my problem jamie_01 1 1,756 Oct-04-2021, 11:55 AM
Last Post: deanhystad
  Question about formula implementation in general format Alienspecimen 0 1,716 Mar-01-2021, 08:39 PM
Last Post: Alienspecimen
  Simple question 1234 4 2,367 Dec-04-2020, 12:29 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020