I define debug_print():
def debug_print(info):
print("[FOO] :",info)
I expect I can call like normal print like this:
name = 'Ujang'
debug_print(name, 'is winner!'); # I expect [FOO] : Ujang is winner!
But it gave me error
TypeError: debug_print() takes 1 positional argument but 2 were given
I tried redefine debug_print parameter with using pointer symbol
def debug_print(*info) but it’s showing tuple format.
# output
[FOO] : ('Ujang', 'is winner!')
>Solution :
You can use join() function without map() as follows:
def debug_print(*info):
print("[FOO] :", ' '.join(info))
name = 'Ujang'
debug_print(name, 'is winner!')
Output:
[FOO] : Ujang is a winner!
Also, as @KellyBundy suggested, you can take advantage of the print() function and pass *info as a parameter, so the print function will automatically convert all of its values to string:
def debug_print(*info):
print("[FOO] :", *info)
name = 'Ujang'
debug_print(name, 'is winner!')