+ 3

What does xi stand for?

x = 2 a = [x**3-1 for xi in range(7)] b = [x**3-1 for x in range(7)] a and b gives different outputs Where is xi defined? What is xi?

6th Aug 2020, 7:52 AM
Tomiwa Joseph
Tomiwa Joseph - avatar
3 Réponses
+ 2
Yes, you are absolutely correct. We can name it anything we want, it's just used to enumerate the number within the range (0 ... 6). I don't know what was meant by that TBH, but if it came from some challenge, perhaps it was meant as a distraction, to test on player's focus : )
6th Aug 2020, 10:51 AM
Ipang
+ 5
<xi> is just another variable used in a list comprehension. The reason why <a> differs to <b> is that the list <a> uses variable <x> which is defined earlier (first line)
6th Aug 2020, 7:59 AM
Ipang
+ 3
Ipang What I have also noticed is that it doesn't have to be xi. It can be anything, eg _, xanything, joseph, ipang, x3 etc. Are you saying xi is meaningless here and that it is meant to confuse?
6th Aug 2020, 10:44 AM
Tomiwa Joseph
Tomiwa Joseph - avatar