+ 2
python
# its did not show else statement "You didn\'t pass anything" its showing op [] def ex1(num,*args): return [i**num if args else 'You didn\'t pass anything' for i in args] nu=[1,2,3] print(ex1(4))
7 Answers
+ 7
Your syntax is not correct.
See if this helps
def ex1(num,*args):
return [i**num for i in args] if args else 'You didn\'t pass anything'
nu=[1,2,3]
print(ex1(4))
print()
print(ex1(4,*nu))
+ 5
Thanks Rik Wittkopp :)
Its working ....
+ 3
If that's the way you've written the code it won't work.
Python is all about the format you write and pay attention to indentation.
E.g.
if statement
print("statement is true")
else
print("other statement")
+ 2
Thanks @Ausgrindtube :)
But I have used list comprehension... I want to do in one line statement..
+ 2
Amol Bhandekar I have just proved that I'm a beginner đ€Ł
Sorry
+ 2
Ausgrindtube
For a beginner, you have excellent knowledge.
Learners like us stick together
0
Fill in the blanks to iterate over the string "str" and output each character.
x
str
print(
)