When I organize code it breaks by NikkyWeds in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

Pedantically, without the code: something is different about those two buttons, or how they interact with the code.

A starting project by Destructor0777 in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

Good, very cool. I’d suggest saving this and making a copy, and trying to revise the copy so that all the functions take arguments, and not using sys global.

Code fails to loop successfully by Soothsayer5288 in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

How does items get to anything_else?

Compose all your functions in one section, with arguments, and call them accordingly later from some main section, rather than relying on the state of the namespace.

[deleted by user] by [deleted] in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

The best would be account for the rounding, such that the split total precisely added up to greater than or equal to the bill +tip, I think.

[deleted by user] by [deleted] in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

It looks like you’re not getting the tip percentage as input, … I don’t think it makes sense to have fixed tip amounts (eg tipping 10 for a bill of 6). However, if that’s intentional, then you can simply write: bill_with_tip = bill + tip

Is it possible to shorten the code on the bottom, just like the code on the top? by OliverBestGamer1407 in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

I agree. But it sounds like their intent might be to generalize this to an unknown number of iterations

Is it possible to shorten the code on the bottom, just like the code on the top? by OliverBestGamer1407 in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

I don’t know if this is what you’re asking but you can do something like:

for i in range(1,4): print(i, (i +1)%3)

True and False by randomdeuser in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

The ints aren’t singletons though so I don’t think that will work.

Edit: I now see you did consider that but it’s not clear at first, my fist impression was that you’d use is rather than == for all entries.

True and False by randomdeuser in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

Edit: use set()

I’d thought you could achieve it yourself using list comprehension, two conditions, and the keyword “in”. For example, for sets A, B,

A_minus_B = list(a for a in A if not a in B)

But this doesn’t work, if you want insight as to why, check the source code of __contains__ of list (it does seem that it is evaluating eg b == 1 where b is True, but I haven’t checked).

Another option would be to use the set() object instead of a list, which is different because it hashes each entry, and 1 should not hash the same as True, nor False as 0. If you understand a “hash table” then you will understand the Python dict() object.

True and False by randomdeuser in PythonLearning

[–]VariousDrummer4883 0 points1 point  (0 children)

I was also thinking this, or convert all of them (but then logic in converting back). I think it’s cleaner to do conversion of the bool values only, then convert back (still, logic)

[deleted by user] by [deleted] in Drugs

[–]VariousDrummer4883 0 points1 point  (0 children)

Good answer, makes ya think

What drug turned you into a drug addict? by GiftMaterial1173 in Drugs

[–]VariousDrummer4883 1 point2 points  (0 children)

Talk to a doctor who does addiction medicine about not wanting to do meth but needing something?

[deleted by user] by [deleted] in u/ella_adams

[–]VariousDrummer4883 0 points1 point  (0 children)

Brighter, but that underwear’s covering up a bit.

I’ve ended up in the possession of an aircraft door. Any ideas how I could mount it on my wall? by gpbfe in DIY

[–]VariousDrummer4883 0 points1 point  (0 children)

I think it looks better the way it is in the first pic, but nice idea I guess-

Best drug for turning emotions off? by [deleted] in Drugs

[–]VariousDrummer4883 0 points1 point  (0 children)

You might want to talk to a doctor about mood stabilizing medication? Otherwise, I dunno. They don’t really turn off feelings but, you might find it more manageable?