I want to format my output like- My choice of fruits are apple Avocado. But not sure it's not executing properly, maybe i'm missing something in formatting. Can you let me know where i'm doing it wrong?
#Kwargs
def my_func(**kwargs):
print(kwargs)
if 'fruit' 'veggie' in kwargs:
print('My choice of fruits are {} {}'.format(kwargs['fruit'],['veggie']))
else:
print('Sorry we can not find your fruit here!')
my_func(fruit='apple', veggie= 'Avocado')
Output of the above snippet coming as- {'fruit': 'apple', 'veggie': 'Avocado'} Sorry we can not find your fruit here!
'fruit' 'veggie' == 'fruitveggie'
['veggie']
is a list
of str
So,
def my_func(**kwargs):
print(kwargs)
if 'fruit' in kwargs and 'veggie' in kwargs:
print(f'My choice of fruits are {kwargs["fruit"]} {kwargs["veggie"]}')
else:
print('Sorry we can not find your fruit here!')
my_func(fruit='apple', veggie='Avocado')