(Jul 27, 2021 09:23 AM)simmer Wrote: Incorrect usage of scope?
Here’s a snippet of code from my program
Code
n = set()
N = set()
k = [n]
for n in N:
a = set((k[n]) == k[n] in set(0, 1))
print(a)
I’m wondering how to print a
At least that’s what I’m saying on here
(Damn firewall)
It's quite hard to understand you, that snippet is a 100% mess.
I don't even know where to start, what's the obsession with set()?
You can't iterate over an empty collection, N is empty -> 'for' loop will not happen -> a is not defined.
You can't iterate over N with n, I'm not sure what you tried to do here, but that param you define for the iteration should be a completely new param,
so saying " for n in N" make no sense here, I mean the param will be n, it will get each value
in N, but it will not be related to the first "n = set()" you defined at the beginning.
also, set() is a function, the base idea of that function is to take a list and return a set,
so far so good, but if you look into set() function you will see it get at most 1 argument,
which means set(0,1) make no sense, the correct way will be set([0,1]), but why even use set here? just type "[0,1]" it 100% percent the same effect here
and even in a more efficient way.
That's an achievement for sure, that 6 lines of code is like having 10 typos in a word that only have 2 chars.
Go back to basics, learn Python from the very beginning.
Also, I have no clue what "firewall" is related to here?
I'm so confused