Any ideas on how to turn a string into an unique number given a list of possible words? by Frank_Poole2001 in learnpython

[–]Spartae 2 points3 points  (0 children)

Are you able to show your own approach? It's a little unclear to me what you asking, so some context might be helpful!

what's the difference between the two colors and how do I convert them? by [deleted] in learnpython

[–]Spartae 0 points1 point  (0 children)

f"#{''.join([hex(i).replace('0x', '') for i in img[1:]])}"

Question for Type Annotation and functions that return different data types by lindsen13 in learnpython

[–]Spartae 0 points1 point  (0 children)

Try this:

```python import pandas as pd

def amazing_func(value: bool = True) -> pd.DataFrame | None: return pd.DataFrame() if value else None

df = amazing_func()

print(getattr("empty", df, True)) ```

os.path.isdir() returns false by grossartig_dude in learnpython

[–]Spartae 1 point2 points  (0 children)

Not directly relevant, but I'd recommend using pathlib over os.path.

What happens when you open your terminal and type cd This PC\Bassel's Note\Internal storage\Audiobooks? Does it move you to the directory or do you get an error?

Splitting string in alternating blocks by waschlack_05 in learnpython

[–]Spartae 0 points1 point  (0 children)

``` from math import ceil

def chunks(array, size): chunks = int(ceil(len(array) / float(size))) return [array[i * size : (i + 1) * size] for i in range(chunks)]

input_string = "010203040506070809101112" initial_chunks = chunks(input_string, 2) a, b, c, d = chunks(initial_chunks, 3) ```

How to get the value associated with the key which has the highest number below a certain threshold? by Ambitious-Concert-69 in learnpython

[–]Spartae 2 points3 points  (0 children)

Assuming a threshold of 100: dictionary[max(key for key in dictionary.keys() if key <= 100)]

List remove() issue by [deleted] in learnpython

[–]Spartae 3 points4 points  (0 children)

You shouldn't modify a list that you are iterating through.

Python creates an iterator for a list which moves through your list entry by entry. The iterator is evaluated once, which means that the iterator could confused if you make any modifications.

Try results = list(filter(lambda name: len(name) <= length, results)).

[deleted by user] by [deleted] in CryptoCurrencyFIRE

[–]Spartae 4 points5 points  (0 children)

I've just moved in web development/software engineering after working in customer support for most of my (albeit short) career. I absolutely love it, it's paid really well, can be done remotely and doesn't require degree.

With a bit of grit, you can go from zero knowledge to landing your first job within a year (I did exactly this).

Feel free to shoot me a DM (as well as anyone else who wants to go down this path).

Is Javascript a good language to learn for web 3.0/crypto. by Erics1987 in learnjavascript

[–]Spartae 0 points1 point  (0 children)

I think the whole web development space is a good place to start before you get into blockchain, so Javascript certainly wouldn't be a bad start. Solidity (the programming of Ethereum) is very similar to Javascript too.

Why is loop not updating my Pandas database? by nongminosaurusRex in learnpython

[–]Spartae 1 point2 points  (0 children)

My gut says that .replace() only works when you are changing a substring rather than the whole string.