Python: finding lowest integer

前端 未结 13 821
北海茫月
北海茫月 2020-12-05 18:16

I have the following code:

l = [\'-1.2\', \'0.0\', \'1\']

x = 100.0
for i in l:
    if i < x:
        x = i
print x

The code should fin

13条回答
  •  广开言路
    2020-12-05 18:37

    l = [-1.2, 0.0, 1]
    
    x = 100.0
    for i in l:
        if i < x:
            x = i
    print (x)
    

    This is the answer, i needed this for my homework, took your code, and i deleted the " " around the numbers, it then worked, i hope this helped

提交回复
热议问题