python program i need help

Posts 1–5 of 5 · Page 1 of 1
python program i need help
this is my program so far

End ]
array = []
amount_of_stock_left = []

print("Welcome to Terence's store, we sell the following items : ")
import csv
with open('Productlist task3.csv')as csvfile:
reader = csv.reader(csvfile)
for row in reader:
print(row)
while True:
fileopener=open("Productlist task3.csv")
for line in fileopener:
End.append(line)
fileopener.close()
sum1=len(End)
print("Please input the gtin product code for the item you wish to purchase")
usersGTIN=input()
for i in range(sum1):
line=End[i]
sum2=line.split(",")
cost=sum2[2]
if sum2[0]==usersGTIN:
sum2[2]=float(sum2[2])
cost=(sum2[2])
product=(sum2[1])
GTIN8=(sum2[0])
stocklevel=int(sum2[3])
print("You have selected:",product)
quantity = int(input("How many of this item do you want to purchase?: "))
final_price=float(quantity*cost)
quantity=int(quantity)
final_price=float(final_price)
GTIN8=int(GTIN8)
wouldyouliketopurchaseanotherproduct = input("Would you like to add another item to your order y/n: ")
if wouldyouliketopurchaseanotherproduct == "y":
continue
elif wouldyouliketopurchaseanotherproduct == "n":
amount_of_stock_left=(stocklevel-quantity)
print((amount_of_stock_left),'left of stock remaining')

https://gyazo.com/590a490be3479a6e 70e772a6e0b7 7f46 (remove spaces) excel file
https://gyazo.com/b359beb1f939ec0dd 6d588354b989 27a (remove spaces) excel file

the output of code- https://gyazo.com/49e 821e3b3f73ddf2c0d615 18134f40a (remove spaces) excel file

i need help on the file, on how to import the data into the excel file (modify it) so that the current stock level amount is changed.If the Current stock level is less than or equal to 5 for example (using yoghurt as example, see screenshot for more info) it would automatically change the current stock to 15 due to being target stock level.
please help
Edit your post and post the code in [code] tags with the white space.
First of all,learn how to give accurate/"good" names to ur variables.

In the name of God,why someone would give a name "woulduliketopurchaseanotherproduct" to a variable?
Also,sum2, sum1=len(End) and later on using it as sum1 in for loop ,hurts ur eyes...

If i understood ur answer correctly (and obviously,this is a part of the code),u need to do some checks into amount_of_stock =(stocklevel-quantity).
Get that number,do the checks,and edit the file.If u dont know how (it looks like u know since u have edited one in the link),just google

If u dont know,just pay someone to teach u/show u
Quote Originally Posted by Kappatos View Post
First of all,learn how to give accurate/"good" names to ur variables.

In the name of God,why someone would give a name "woulduliketopurchaseanotherproduct" to a variable?
Also,sum2, sum1=len(End) and later on using it as sum1 in for loop ,hurts ur eyes...

If i understood ur answer correctly (and obviously,this is a part of the code),u need to do some checks into amount_of_stock =(stocklevel-quantity).
Get that number,do the checks,and edit the file.If u dont know how (it looks like u know since u have edited one in the link),just google

If u dont know,just pay someone to teach u/show u
could help me make python create blank excel file which contains the following details:

GTIN-8 Product name currentstock

The current stock is the currentstock minus the use quantity input
I told u exactly what to do ,and if u dont know how to edit it etc,just use google.
Check if the stock level is lower than 5,stock level is 15.Thats the only thing when it comes to fixing the value.

I gave u the hint,go on and code it.Sry i dont code for free
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us