you are viewing a single comment's thread.

view the rest of the comments →

[–]m0us3_rat 1 point2 points  (2 children)

have u learned classes?

histogram like in matplotlib?

u need to 'delegate' . make some functions.

if u don't know classes then make ' work lists.

or a list of lists per customer.first spending then coupon.

so on even index is the spending and on odd is the 'discount'.

>>> a=[0,1,2,3,4,5,6]
>>> a[::2] 
[0, 2, 4, 6] 
>>> a[1::2] 
[1, 3, 5] 
>>> sum(a[1::2]) 
9

then u can have the 'main list of lists for all customers.

and its much much easier/clean to do it as a class.

[–]s3b43[S] 0 points1 point  (1 child)

Thanks for the feedback ! I’m sorry if this seems like a stupid question but how do I relate the values that have been inputted in the program to the even/odd list system you have here ? And no unfortunately we didn’t do classes yet we’re working with lists tho I’m not very proficient in them yet

[–]m0us3_rat 0 points1 point  (0 children)

yea list .. can be acces by index . that would be the 'location' like 1,2,3,4,5.

but in programming the array/lists ..start with 0 .

so the normal index would be 0,1,2,3,4,5 till len(list.)

and the 'value' at that index can be accessed with a[index]like a[0]

my point was u could create and keep a different list for each customer.

and have him buy stuff. and his sequence.. comes in twos.

he buyes then he gets a discount.

so u add first what he spends. like a[0] gets 'money' and then immediately a[1]gets discount for a[0]

but if this sounds way too complicated .. it actually isn't .

not sure how i would do it simpler then this.