Yes, zip is great. But your original is only longer because it sets name and age as variables, either for readability, better debugging or unfamiliarity with format string capabilities.
One unfamiliar with zip would write the first one as:
names=['Alice','Bob','Charlie']ages=[30,25,35]fori,nameinenumerate(names):print(f'{name} is {ages[i]} years old')
Welcome to my profile! I am a chemical engineering student and a backend developer with a passion for Python and web scraping. I specialize in Django and full stack development. Please enjoy my posts!
I admire your mindset; it's a fantastic approach! Essentially, what I'm aiming for is to create very simple code tailored for budding ninja coders. I provide small examples showcasing the usage of the built-in 'zip' function.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yes, zip is great. But your original is only longer because it sets name and age as variables, either for readability, better debugging or unfamiliarity with format string capabilities.
One unfamiliar with zip would write the first one as:
And then it's equally long.
I admire your mindset; it's a fantastic approach! Essentially, what I'm aiming for is to create very simple code tailored for budding ninja coders. I provide small examples showcasing the usage of the built-in 'zip' function.