How do you create and add int/float?



  • def min(ls=0.0):#
        for i in c2:#take by 1 element
            a,b=srsumm(i)#summ/count
            c=a/b#average
            ls+=round(c,1)
        print(ls)
        return ls
    

    In fact, it's necessary to record data in ls as in boxes [1.2.3] and not 1+2+3=6.

    How do you make a cortege of ls and add value to it?



  • You need a list, not a box. Cortege is an intangible data structure, so adding elements into it is possible only through re-establishment, which is why it's rather inefficient (maybe you're just misrepresenting the list because you're giving an example of the list syntax, not cortege).

    To create an empty list is easy:

    lst = []
    

    Components are added using methods append and extend (sighs)extend Replacement by operator +=but it must be borne in mind that this method adds a list rather than one meaning:

    lst.append(10)      # [10]
    lst.extend([1, 2])  # [10, 1, 2]
    lst += [5]          # [10, 1, 2, 5]
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2