Home > Software design >  Why is my input statement not transferring float into the list?
Why is my input statement not transferring float into the list?

Time:05-21

Pycharm Screenshot!

#Accept a list of 5 float numbers as an input from the user numlist=[]

for i in range(0,5): numlist[i]=numlist.append(float(input("Input a number:")))

print(numlist)

#Output: [None, None, None, None, None]

CodePudding user response:

Remove numlist[i]=. The append method returns None hence the elements in the list are being replaced with None.

  • Related