Gtting input ina loop

I want to get the inputs in a loop and I want to show the user they are entering data for the 1st,2nd,3rd, etc items in that loop, can anyone help me please with fixing my code?

n=int(input("Pleaseenter the number of laptops: "))
i=0
while i!=n:
laptops_price=input("Please enter the price of the {i}laptop: ".format(i))
i+=1

>Solution :

You have confused f strings with format calls. They are not quite the same. Either of these will work:

laptops_price=input(f"Please enter the price of the {i}laptop: ")
laptops_price=input("Please enter the price of the {}laptop: ".format(i))

Leave a Reply