'Wanna know the how the compiler is processing this piece of code [closed]
Here's the piece of code- I just wanna know how the compiler is processing line 5 here. Like I wanna know in detail what's happening in line 5 (e=b[d]).
import random
a=input("Please type some names- ")
b=a.split(",")
c=len(b)
d=random.randint(0,c-1)
e=b[d]
print(e)
Solution 1:[1]
As you asked in your comment above, line 6 accesses a list, b, at index d, d is a random integer from the range 0 to the length of the list.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | shr4pnel |
