6
fantasy
6y

Can you explain to me how it works?Please

Comments
  • 9
    I believe u are using python language and the out put is 2 btw

    L is an empty list
    N is initalized to one

    You have aloop that checks if n is less than 15

    Inside your loop you append in L your N value you also add 1 to your N value each loop

    Lastly you have print l[1] that access your L index 1 which is 2
  • 3
    Since python arrays start with 0, the array will be like [1,2,3,...,14]. So the output is 2.
    I hope this is correct; python isn't my language of choice

    EDIT: what he said ^ 😁
  • 0
    I Confirm their answers lol
  • 0
    @rui725 Thank you,I got it.
  • 0
    I remember you (?) asked something similar before, are you trying to cheat your buddy, that is playing these challenges with you? 😉
  • 0
    Never ever loop like this in Python. Learn to use the idioms or use something else.
  • 0
    Which app?
  • 0
    @hube list comprehension is the pythonic way ;)
  • 0
    @ShahriyarRulez SoloLearn
Add Comment