Answers for "list int python"

9

convert list into integer python

num = [1, 2, 3, 4]

s = [str(i) for i in num] # Converting integers into strings

result = str("".join(s)) # Join the string values into one string

print(result)
Posted by: Guest on June-16-2020
0

nums: List[int] in python function

from typing import List
Vector = List[float]

def scale(scalar: float, vector: Vector) -> Vector:
    return [scalar * num for num in vector]

# typechecks; a list of floats qualifies as a Vector.
new_vector = scale(2.0, [1.0, -4.2, 5.4])
Posted by: Guest on September-26-2020

Python Answers by Framework

Browse Popular Code Answers by Language