-3

This question has already been asked here: Python equivalent of R c() function, but unfortunately the solution given doesn't exactly apply to me.

For instance, if I combine values, into a vector or list, in R like so:

x = c(2,3,6,8)

I can preform calculations on that list, for example:

x*2
Output:
4 6 12 16

However, I'm not sure how to achieve the same thing in Python. The previously asked question (in the link above) deals with a list of numbers in a particular range. for example,

x = list(range(1:10))

I am wondering, how do I define a list of numbers (not in a range) in Python?

Electrino
  • 2,636
  • 3
  • 18
  • 40

1 Answers1

-2

in python, you could use numpy arrays to do such things

import numpy
x = numpy.array([2, 3, 7])
y = x*2 

and y will be equal to numpy.array([4, 6, 14])

evinoshea
  • 32
  • 5