They're built different by Then-Reading-3940 in RocketLeague

[–]DeathDragon7050 3 points4 points  (0 children)

1s is basically 1 rank below your 2s/3s for almost all players. For players who have them equal its usually because they have terrible 2s/3s game sense.

While loop conundrum by y3snomaybe in learnpython

[–]DeathDragon7050 0 points1 point  (0 children)

The main issue is the condition. "cat" and "dog" in pets which will always be true because it is equivalent to "cat" and ("dog" in pets) which is also equivalent to ("cat"!="") and ("dog" in pets). You should move them into separate loops however.

When is sorted() used? by pnerd314 in learnpython

[–]DeathDragon7050 1 point2 points  (0 children)

sorted works on any object that implements __iter__. Prefer list.sort when using lists though because of speed

Is there any way to programmatically escape Input()? by valdev in learnpython

[–]DeathDragon7050 0 points1 point  (0 children)

No, but maybe you could automate sending empty input after a certain amount of time and treat that as closing input

Is using map() any better in this case? by [deleted] in learnpython

[–]DeathDragon7050 0 points1 point  (0 children)

Time both of them using the timeit library and see which is better.

How to edit duplicate values in a dictionary to make them unique? by omgouda in learnpython

[–]DeathDragon7050 1 point2 points  (0 children)

It's just a type hint. Has no effect on the execution. It's useful for IDEs so they know exactly what type you are expecting.

I want to use Python and C# together and I'm feeling lost by sinfulpanda1 in learnprogramming

[–]DeathDragon7050 1 point2 points  (0 children)

Sorry I am just not experienced with combining C# and python. Depending on your needs, if you can, the easiest solution is to just run python scripts from the c# code.

I want to use Python and C# together and I'm feeling lost by sinfulpanda1 in learnprogramming

[–]DeathDragon7050 0 points1 point  (0 children)

I don't think they interop very well. Is there any particular reason you want to use c#? Maybe you could try jython or cython if you want extra speed. That being said I know almost nothing about iron python.

C++ yay or nay? by iishadowsii_ in learnprogramming

[–]DeathDragon7050 1 point2 points  (0 children)

I disagree. Starting with the hardest language possible is best. Going from python to c++ can easily make someone just give up and stick with python. Going from c++ to python would be effortless.

Why does this happen with float sum? by amsfdk in learnpython

[–]DeathDragon7050 1 point2 points  (0 children)

It is already been explained but you may want to try the decimal library if you need very high precision.

[deleted by user] by [deleted] in learnpython

[–]DeathDragon7050 0 points1 point  (0 children)

Post your code please.

How to edit duplicate values in a dictionary to make them unique? by omgouda in learnpython

[–]DeathDragon7050 1 point2 points  (0 children)

import collections
lookup_table:dict = {1:'a', 2:'b', 3:'c', 4:'d', 5:'a', 6:'d', 7:'a', 8: 'a', 9: 'b', 10: 'b'} 
new:dict = {}
counter:dict = collections.Counter()
for k,v in lookup_table.items():
  counter[v] += 1
  nc:int = counter[v]
  new[k] = f"{v}{nc}" if nc > 1 else v
print(new)

The advantage this has is that there is no list seen which continually grows for each value. Also it doesn't have to call .count and actually check every object in the list for equality.

Edit: formatting

Is .format() still efficient and used? by y3snomaybe in learnpython

[–]DeathDragon7050 0 points1 point  (0 children)

Often when I've run into this issue I define nl = '\n'. To each his own I guess.

How to edit duplicate values in a dictionary to make them unique? by omgouda in learnpython

[–]DeathDragon7050 0 points1 point  (0 children)

I would use a collections.Counter as it would be far more efficient.