[Tutor] Need help - getting Tuple index out of range
Mark Lawrence
breamoreboy at gmail.com
Wed Feb 5 13:35:30 EST 2020
On 05/02/2020 05:34, Abhinava Saha wrote:
> Hi all,
>
> I am a beginner in python, Someone please help me fix the program below on tuple, getting error touple index out of range.
>
> def full_email(peoples):
> result = []
> for index, (name, email) in enumerate(peoples):
> result.append("{} <{}>".format("name, email"))
> return result
>
> print(full_email([('Abhinava', 'abhinava at abc.com'), ('Manoj', 'manoj at xyz.com')]))
>
>
> Regards,
> Abhinava
>
As you've all ready had answers I'll just point out that you can use
list comprehensions
https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions
instead of the for loop to achieve the same result. Writing the code is
left as an exercise for any reader :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Tutor
mailing list