Question

Using Python, write a function named add_surname that takes as a parameter a list of first...

Using Python, write a function named add_surname that takes as a parameter a list of first names. **It should use a list comprehension** to return a list that contains only those names that start with a "K", but with the surname "Kardashian" added to each one, with a space between the first and last names. For example, if the original list is:
```
["Kiki", "Krystal", "Pavel", "Annie", "Koala"]
```
Then the list that is returned should be:
```
['Kiki Kardashian', 'Krystal Kardashian', 'Koala Kardashian']

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def add_surname(data):

#if x starts with K than add Kardashian and append to res

res=["Kardashian "+x for x in data if x.startswith("K")]

return res

print(add_surname(["Kiki", "Krystal", "Pavel", "Annie", "Koala"]))

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Using Python, write a function named add_surname that takes as a parameter a list of first...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT