Answers for "how to get args in python"

0

python get args

import sys

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

args in python

# normal parameters with *args

def mul(a,b,*args): # a,b are normal paremeters
    multiply = 1
    for i in args:
        multiply *= i
        
    return multiply

print(mul(3,5,6,7,8))   # 3 and 5 are being passed as a argument but 6,7,8 are args
Posted by: Guest on June-24-2021
0

args in python

def display(a,b,c):
    print("arg1:", a)
    print("arg2:", b)
    print("arg3:", c)

lst = [2,3]
display(1,*lst)
Posted by: Guest on June-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language