Python Forum
misunderstanding of format in print function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
misunderstanding of format in print function
#2
Because you unpack and have four values which will not fit into three placeholders so the last one will be skipped. Observe:

>>> client_address = ('192.168.167.200', 49706) 
>>> message = 396                                                                          
>>> print(*client_address, client_address[1], message)                                     
192.168.167.200 49706 49706 396
In two lines you skip the third value in first line. So if you look for solution skip 'client_address[1]' in your original code and everything should be fine.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
RE: misunderstanding of format in print function - by perfringo - Oct-29-2019, 12:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 473 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  How to print variables in function? samuelbachorik 3 1,063 Dec-31-2022, 11:12 PM
Last Post: stevendaprano
  How to print the output of a defined function bshoushtarian 4 1,460 Sep-08-2022, 01:44 PM
Last Post: deanhystad
  .format function Menthix 6 1,847 Mar-12-2022, 10:32 AM
Last Post: stevendaprano
  use of format function barryjo 3 1,802 Feb-01-2022, 08:07 AM
Last Post: menator01
  Why does absence of print command outputs quotes in function? Mark17 2 1,518 Jan-04-2022, 07:08 PM
Last Post: ndc85430
  return vs. print in nested function example Mark17 4 1,921 Jan-04-2022, 06:02 PM
Last Post: jefsummers
  Date format and past date check function Turtle 5 4,703 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  Print first day of the week as string in date format MyerzzD 2 2,149 Sep-29-2021, 06:43 AM
Last Post: MyerzzD
  output correction using print() function afefDXCTN 3 11,448 Sep-18-2021, 06:57 PM
Last Post: Sky_Mx

Forum Jump:

User Panel Messages

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