0

I am new to python stuck with the issue of not getting the list after appending using the *args to fetch every element.

def has_33(*args):
    m=[]
    for i in args:
        m = m.append(i)
    print(m)
has_33([1,3,3])

output

None
Sagar Dixit
  • 1
  • 1
  • 1

2 Answers2

1

You can do something like this:

def has_33(*args):
    m=list(args)
    print(m)
has_33([1,3,3])

And if you don't need the list you can do this:

def has_33(*args):
    m=list(args)
    n = []
    for l in m:
        for elem in l:
            n.append(elem)

    print(n)
has_33([1,3,3])
abhigyanj
  • 2,355
  • 2
  • 9
  • 29
1

Remove m=m.append(i) and write like this m.append(i) This works.

Varun Kumar
  • 153
  • 11