Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Create a loop that puts a word from the list into the link

I have created a sample list of list1 = ["a", "b", "c", "d"]. I would like to create a new list with a loop, in which the items from list1 would be saved, connected with an https link. In list2, the items in the list would look like this: "https://www.google.com/a", "https://www.google.com/b" …. How to do is in python3?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can do:

base_url = 'https://www.google.com/'
list1 = ["a", "b", "c", "d"]
list2 = [f"{base_url}{item}" for item in list1]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading