Skip to content

Polygon perimeter calculator  #4013

@EliKanevski

Description

@EliKanevski

For some reason when i assign a list to x this works perfectly fine, but when i take a list input i get an error. Does anyone know why?
Thank you.

print('*** QUESTION 4 ***')
def perimeter(points):
    d = 0
    len_points = len(points)
    if len(points) < 3:
        return 0
    for i in range(len_points):
        d += math.sqrt((points[i-1][0] - points[i][0])**2 + ((points[i-1][1] - points[i][1])**2))
    return d
x = list(input('please enter a list'))
print(type(x))
print(perimeter(x))```                                                                                                                                                              

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions