0

I would like to take the randomized numbers of the first column of my array, find their absolute values, and store them in my second column. So far i've written this code:

import random
nb = int(input("Enter a number : "))
tab = [[random.randint(-10, 10) for i in range(nb)], []]
print(','.join(str(n) for n in tab))

Thanks in advance !

mail2subhajit
  • 1,106
  • 5
  • 16
Balek
  • 3
  • 1
  • You can get the absolute value of numbers using `abs()`, but what about your "second column" I don't understand how or where that fits. – Sami Farhat Feb 22 '20 at 21:00

1 Answers1

0
for i in range(nb): tab[1].append(abs(tab[0][i]))
Ben
  • 452
  • 4
  • 9