I would expect the output to be like [[1,2,3,4,5,6,7,8,9,10],[2,4,6,8,10,12...18,20],[3,6,9...27,30].....[9,18,27..90]]

I'm using python.I need to get output as I mention in bottom. This is the way I try.

 L = [i for i in range(1,11)]
    print(L)
    p = []
    p.extend(L for _ in range(10))
    #print(p)
    for _ in range(10):
        for i in range(10):
            p[_][i] = (_+1)*p[_][i]
    print(p)
and this is the output I got.

Output:[[3628800, 7257600, 10886400, 14515200, 18144000, 21772800 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000]]

I would expect the output to be like

[[1,2,3,4,5,6,7,8,9,10],[2,4,6,8,10,12...18,20],[3,6,9...27,30].....[9,18,27..90]]

There are several problems: Do not use _ as a variable name it's for variables you won't reuse.

You are getting this problem because of this line:

p.extend(L for _ in range(10))

p is a list of references to L. So when you do:

p[_][i] = (_+1)*p[_][i]

you modify L, and thus all the lists in p.

Your code fixed:

p = []
p.extend(list(range(1,11)) for _ in range(10))

for i in range(10):
    for j in range(10):
        p[i][j] = (i+1)*p[i][j]
print(p)

However, there is a simpler way to do it:

p  = [ list(range(i, i*11, i )) for i in range(1,10)]

[PDF] Section 2 Answer Key: 0) Find the median and quartiles of each of , 5. 16 1. 22 18. 6. 12 21 23 9. 10 24 21 17 11 18 19 17 5. 14 16 19 19 18 3. 4. 21 16 20 15 14 17 4. 5. 22 12 15 18 20 8. 10 13 20 6. 9. 2. 17. 15 9. 4 (500,000)2. 8. 7. = 79,372.54. Seven out of eight employees earn less than the mean (the  Start studying Set Operations ( U={1,2,3,4,5,6,7,8,9,10,11,12} A={3,6,9,12} B={2,4,6,8,10} C={1,3,5,7,9} D={1,4,7,10} ). Learn vocabulary, terms, and more with

L = [i for i in range(1,11)]
print(L)
d = []
for i in range(1, 11):
    d.append([i * j for j in L])

print(d)

output:

[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [6, 12, 18, 24, 30, 36, 42, 48, 54, 60], [7, 14, 21, 28, 35, 42, 49, 56, 63, 70], [8, 16, 24, 32, 40, 48, 56, 64, 72, 80], [9, 18, 27, 36, 45, 54, 63, 72, 81, 90], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]

I think answer is 90 there are many answers which one is correct 2=6 3, 2 x 3= 6. 3 x 4 = 12. 4 x 5 =20. 5 x 6 =30. 6 x 7 =42. 7 x 8 =56. 8 x 9 = 72. 9 x 10= 90. Answer = 90. There's also another logic to it let the number be n. 1 minute ago A model of an airplane is shown below 3.0 inches,1.25 inches. A.936in B.1,170in C.1,250in D.2,340

You can use a list comprehension:

new_data = [list(filter(lambda x:not x%i, range(i, (10*i)+1))) for i in range(1,10)]

Output:

[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [6, 12, 18, 24, 30, 36, 42, 48, 54, 60], [7, 14, 21, 28, 35, 42, 49, 56, 63, 70], [8, 16, 24, 32, 40, 48, 56, 64, 72, 80], [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]]

Mergesort, This mergesort is the basis for high-performance segmented and locality sorts that 55 Sorted output: 0: 1 4 5 5 6 6 7 7 8 9 10: 10 13 13 14 14 16 16 17 17 18 20: 18 58 90: 2 4 42 76 31 49 16 48 17 42 Sorted keys: 0: 0 1 2 3 4 6 7 8 10 12 10: 78 3 10: 14 50 23 36 96 12 18 43 98 11 20: 28 44 75 54 41 53 7 39 60 66 30:  Suppose that the universal set is U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. Express each of these sets with bit strings where the ith bit in the string is 1 if i is in the

moderngpu.github.io/mergesort.html at master · moderngpu , 0: 1 4 5 5 6 6 7 7 8 9. 10: 10 20: 3 6 56 13 88 8 66 0 19 45 0: 0 1 2 3 4 6 7 8 10 12 3. 10: 14 50 23 36 96 12 18 43 98 11 <span class="green">9 12 13 18 22 27 30 54 54 63 83 90 91 95 96 99</span></pre></div> This allows mergesort to efficiently handle types like strings by calling <code>strcmp</code> from the  Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

Prime Factorization Calculator, Examples of this include numbers like, 4, 6, 9, etc. As an example, the number 60 can be factored into a product of prime One method for finding the prime factors of a composite number is trial Prime factorization of 7: prime number. Prime factorization of 8: 23. Prime factorization of 9: 32. Prime factorization of 10: 2 × 5. Time for a crash course on arrays in C. First of all, let's fix the initializer for the array: int a[3][4] = { { 1, 2, 3, 4}, { 5, 6, 7, 8}, { 9, 10, 11, 12} };

Kata Retrospective: Find the cheapest path, from random import randint toll_map = [[randint(1, 100) for _ in range(100)] for _ in If it WAS a list of columns, it'd be explicitly stated like in this kata (as it's an {​37,4 ,41,76,85,63,2 ,47,69,44,19,23,25,11,58,66,98,8,49,86,24,34,7,94,46,37,53 57, 48, 9, 59], [89, 73, 70, 10, 6, 63, 74, 71, 5, 67, 43, 1, 60, 52, 82, 26, 75, 3, 52​  1. Write a program in C to display the first 10 natural numbers. Go to the editor. Expected Output : 1 2 3 4 5 6 7 8 9 10. Click me to see the solution. 2. Write a C

Comments
  • The question is : how to get the expected output or why do you get that strange output ?
  • Some further info on this can be found here: nedbatchelder.com/text/names1.html
  • Hi, you said L is modified after the line p[][i] = (_+1)*p[][i] is executed but when I print L, in the end, It still retains its initial value.
  • so my question is: If L is changing then why don't I see the change when I print it again in the end?
  • If I copy/paste your code and print(L) in the end L is worth : [3628800, 7257600, 10886400, 14515200, 18144000, 21772800, 25401600, 29030400, 32659200, 36288000], it is modified
  • yeah, yes you were right, It indeed did change. But do you know why the starting value of the list ended up to be 3628800??
  • That's great, But I just want some help in figuring out why my approach leads to a different output as opposed to what I expect it to be.