Answers for "python how to use args"

0

python get args

import sys

print(sys.argv)
Posted by: Guest on February-23-2021
1

python *args

# concatenate_keys.py
def concatenate(**kwargs):
    result = ""
    # Iterating over the keys of the Python kwargs dictionary
    for arg in kwargs:
        result += arg
    return result

print(concatenate(a="Real", b="Python", c="Is", d="Great", e="!"))
Posted by: Guest on November-27-2020
0

args in python

def mul(*args):  # args as argument
    multiply = 1
    for i in args:
        multiply *= i
        
    return multiply

lst = [4,4,4,4]
tpl = (4,4,4,4)    

print(mul(*lst))  # list unpacking
print(mul(*tpl)) # tuple unpacking
Posted by: Guest on June-24-2021
0

args in python

def func2(*args):
    for i in args:
        print(i * 2)
        
func2(2,3,4,5)
Posted by: Guest on June-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language