isdsucph / isds2021

Introduction to Social Data Science 2021 - a summer school course https://isdsucph.github.io/isds2021/
MIT License
22 stars 37 forks source link

ex 0.5.0 #22

Closed frederikfogh closed 3 years ago

frederikfogh commented 3 years ago

Hi Joachim,

I hope you have time to help, despite the deadline for the submission is fast approaching :-)

Essentially, I am struggling with interpreting how to combine the list of endpoints ("en", "dk") with the change_url fkt. Thus, when I simply define char= ["en", "da"] and subsequently run the function, it reads the variable as a string instead of a list, which consequently gives me one wrong output. I would suppose I don't have to use a loop, as we utilize the f-string?

[Uploading Screenshot 2021-07-27 at 10.16.19.png…]()

Kind regards, Frederik :-)

def change_url(chars): url = f"https://www.dst.dk/{chars}/" return url chars=["en", "da"] change_url(chars)

"https://www.dst.dk/['en', 'da']/"

joachimkrasmussen commented 3 years ago

Hi Frederik,

Two things:

  1. It seems that you are working on the assingment from last year, doesn't it? How can this be? If this is the case, you can send me an email and we can see if we can sort it out.
  2. Here, you want to loop through each element in your list and use it as argument in your function. So you want to do something like what I do below. Then it's up to you what you do with the output (instead of printing).

Best, Joachim

for chars in ["en", "da"]:
    print(change_url(chars))
frederikfogh commented 3 years ago

I have send you a message on absalon :-)