[Solved] Grocery Store for Python

I think the problem is in the part where you insert your item into the cartList. You only insert the item, not the money with it. So in the return part, it must be: if ask == ‘return’: ret = input(‘What item do you want to return?\n’) for i in cartList: if ret==i: … Or … Read more

[Solved] Pass variables through functions in Python 3

Your start function explicitly allows access to a global variable named var. As evidenced by your error, you have no such variable defined. Please initialize the variable before the function: var = 25 def start(): global var # the rest of your function # goes here after global var 3 solved Pass variables through functions … Read more

[Solved] for i in xrange() not running the complete script

Thanks Eric. This line of yours: “Presumably the second call to thr_tip.SetPoint discards whatever changes were made on the for call” put me on the right track. This is my new script and it works perfectly: for i in xrange(len(thr_tip_init)): pitch_list.append(pitch_dest[i] – thr_tip_init[i]) crest_list.append(crest_dest[i] – thr_tip_init[i]) pitchM_pos = Pitch * pitch_list[i] + thr_tip_init[i] crestM_pos = … Read more

[Solved] what program should i use to code using the Python PyGame module [closed]

You can install pygame with following this; open cmd(console) and write this codes: pip install pygame Easiest way for this. For mac; sudo pip install pygame And yes you have to write this in terminal Or download from here http://www.pygame.org/download.shtml manually. But my little advice is, pygame is not so simple, first improve yourself in … Read more

[Solved] Python output on a separate lines

You are removing the newline characters “\n” from each line in the file with the statement:- line=line.strip() Just remove it and it should work correctly. solved Python output on a separate lines

[Solved] Making new list of lists from elements of some other lists

A pythonic implementation. [i.append(Origin[0][0]) for i in Points] print [[item1[0],item1[-1],item2] for item1,item2 in zip(Points,Distance)] Result [[‘A’, ‘J’, 0.28], [‘B’, ‘J’, 0.23], [‘C’, ‘J’, 0.3], [‘D’, ‘J’, 0.22], [‘E’, ‘J’, 0.75], [‘F’, ‘J’, 0.37], [‘G’, ‘J’, 0.17], [‘H’, ‘J’, 0.09], [‘I’, ‘J’, 0.13], [‘J’, ‘J’, 0.0]] solved Making new list of lists from elements of some … Read more

[Solved] Rounding datetime based on time of day

there could be a better way to do this.. But this is one way of doing it. import pandas as pd def checkDates(d): if d.time().hour < 6: return d – pd.Timedelta(days=1) else: return d ls = [“12/31/2019 3:45:00 AM”, “6/30/2019 9:45:00 PM”, “6/30/2019 10:45:00 PM”, “1/1/2019 4:45:00 AM”] df = pd.DataFrame(ls, columns=[“dates”]) df[“dates”] = df[“dates”].apply(lambda … Read more

[Solved] Keeping random name in Python

The MakeSentence(): finishes once it hits the return statement, so you have several print statements that execute after that seemingly repeated again? You could have this return a list or tuple: def MakeSentence(): #makes sentence by combining name, verb, and noun “”” (None)->List Returns a list with a random name, verb and noun “”” x … Read more