Skip to content
Advertisement

Learning Python: Printing Variable Key Arguments

I’m trying to write a program that can take and print a variable number of arguments. The code is below. My code works, however, the format of the output is not what I am trying to achieve. Can someone help me work around the output?

Desired output:

{'first': 'Steve', 'last': 'Cook'}

My output:

first:Steve

last:Cook
def full_name(**data):
   for key, value in data.items():
      print(f"{key}:{value}")
    
first = input()
last = input()
    
full_name(first = first, last = last)

Advertisement

Answer

I apparently went too far I guess? This is the proper coding, thanks everyone for the help.

def full_name(**data):
    print(data)

first = input()
last = input()

full_name(first = first, last = last)
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement