I wrote a program to print strationary item that accepts the product and price and print it. But it's not working y? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

I wrote a program to print strationary item that accepts the product and price and print it. But it's not working y?

n=input() x=[] y=[] for i in range(0,n): a=input("enter the item no",i+1) b=int(input()) x.append(a) y.append(b) for i in range (0,n): print("{}.{} - ₹{}".format(i,x[i],y[i]))

2nd Jun 2020, 7:59 AM
Vicky
Vicky - avatar
16 Antworten
+ 3
n=int(input()) x,y=[],[] for i in range(0,n): a=input("enter the item") b=int(input("enter the price")) x.append(a) y.append(b) for i in range(0,n): print("{}.{} - ₹{}".format(i+1,x[i],y[i]))
2nd Jun 2020, 8:44 AM
Vicky
Vicky - avatar
+ 3
You can't pass more than 1 arguments in input() function. And also change "n" to int for loop to run
2nd Jun 2020, 8:06 AM
Arsenic
Arsenic - avatar
+ 3
n=int(input()) Also input can't contain two arguments ,remove that ",I+1" from a=input("enter the item no",I+1)
2nd Jun 2020, 8:07 AM
Abhay
Abhay - avatar
+ 1
Thats not how it works. 3 people just told you the answer, figure it out. If you still have trouble, you may want to read that bit again
2nd Jun 2020, 8:09 AM
Slick
Slick - avatar
+ 1
Inputs should be 3 Apple 30 Orange 40 Grapes 50
2nd Jun 2020, 8:28 AM
Abhay
Abhay - avatar
0
Whats the expected output? And whats the error? It seems fine exept for the ",i+1" part where you take input for the variable 'a'.
2nd Jun 2020, 8:07 AM
Slick
Slick - avatar
0
Plz correct it and answer me
2nd Jun 2020, 8:07 AM
Vicky
Vicky - avatar
0
U didnt get the price from the user
2nd Jun 2020, 8:27 AM
Vicky
Vicky - avatar
0
Out put should be apple - Rs 30 Orange - Rs 40 like that
2nd Jun 2020, 8:29 AM
Vicky
Vicky - avatar
0
Input is as u said...
2nd Jun 2020, 8:30 AM
Vicky
Vicky - avatar
0
No u didnt get the price?!
2nd Jun 2020, 8:34 AM
Vicky
Vicky - avatar
0
And it's showing track back error
2nd Jun 2020, 8:36 AM
Vicky
Vicky - avatar
0
Tq I corrected myself
2nd Jun 2020, 8:44 AM
Vicky
Vicky - avatar
0
Here Is The Solution Of Your Query : https://code.sololearn.com/cm490OxX5c5A/?ref=app
2nd Jun 2020, 9:09 AM
Rahul Saxena
Rahul Saxena - avatar
0
Vicky Try this. This will work fine. It won't work as you expect in Sololearn's editor. Try it on any other editor. n = int(input()) x, y = [], [] for i in range(0,n): print("Enter the product name.") a = input() print("Enter the price.") b = int(input()) #or typecast to float x.append(a) y.append(b) for i in range (0,n): print("{}. {} - ₹{}".format(i+1,x[i],y[i]))
3rd Jun 2020, 10:05 PM
Sharique
- 1
Sss
2nd Jun 2020, 8:29 AM
Vicky
Vicky - avatar