Uit een python tutorial, de beschrijving van de opdracht:
Ik krijg vervolgens dit:
Uit de code maak ik op dat het 10 moet zijn, en niet 20. Waarom zou dat 10 moeten zijn. Twiekers die hier het antwoord weten?
De opdracht uit de tutorial die ik gewijzigd heb:The target of this exercise is to create two lists called x_list and y_list, which contain 10 instances of the variables x and y, respectively. You are also required to create a list called "big_list", which contains the variables "x" and "y", 10 times each, by concatenating the two lists you have created.
Python:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| x = object() y = object() # change this code x_list = [1,2,3,4,5,6,7,8,9,10] y_list = [11,12,13,14,15,16,17,18,19,20] big_list = x_list + y_list print "x_list contains %d objects" % len(x_list) print "y_list contains %d objects" % len(y_list) print "big_list contains %d objects" % len(big_list) # testing code if x_list.count(x) == 10 and y_list.count(y) == 10: print "Almost there..." if big_list.count(x) == 10 and big_list.count(y) == 10: print "Great!" |
Ik krijg vervolgens dit:
code:
1
2
3
| x_list contains 10 objects y_list contains 10 objects big_list contains 20 objects |
Uit de code maak ik op dat het 10 moet zijn, en niet 20. Waarom zou dat 10 moeten zijn. Twiekers die hier het antwoord weten?