Is this correct? How do i fix the error?
for i in range(10):
for j in range(10):
if(list[i] != alpha[j])
What do you want it to do? What does it do? Error message? Give a little more information.
BTW: Don't call a variable list, this is a keyword in Python ;)
Mawe is right! Using Python keywords as variable names in your code can lead to nasty errors. Otherwise your code should work the following way ...
# test
list1 = range(10)
alpha = range(10, 0, -1)
print list1 # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print alpha # [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
for i in range(10):
for j in range(10):
if (list1[i] != alpha[j]):
print list1[i], alpha[j] # skips 1,1 2,2 etc.
This adds a temporay print statement to test your code's logic.
:mrgreen: Thank You. My Error is using the python keyword list.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.