Python’s default multiplication of a Sequence is "concatenate the Sequence with itself N times" - and is therefore defined only for sequences X integers.
Apparantly you intend to have each Member of the Sequence multiplied in place, and may have overheard someone telling you to use map
.
map
is a built-in to perform one Operation on each Member of a Sequence, and it would work like this:
new_list = list(map(lambda element: element * float_value, original_list))
Python has a short syntax for that in the form of list comprehensions, Where one can put an Expression directly, Instead of Passing a Function as a Parameter to map
:
new_list = [element * float_value for element in original_list]
Welcome to Stackoverflow in English. As the name suggests, the official language used here is Portuguese. So, could you please translate your question? If you prefer, you can also ask the same question on the Stackoverflow website.
– KALIBBAN