r/pythonhelp • • Dec 15 '23

why does 3x = 1i?

computer_list = [1,2,3,4];
user_list = [1,4,3,7];
def check_values(computer_list, user_list):
for i in range(4):
if user_list[i] == computer_list[i]:
print("red")
elif user_list[i] != computer_list[i]:
for x in range(4):
if user_list[i] == computer_list[x]:
print("white")
print(x)
print(i)

check_values(computer_list, user_list)

4 Upvotes

7 comments sorted by

•

u/AutoModerator Dec 15 '23

To give us the best chance to help you, please include any relevant code.
Note. Do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Repl.it, GitHub or PasteBin.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/carcigenicate Dec 16 '23

Please format your code and describe what you mean.

1

u/[deleted] Dec 16 '23

Short answer: I have no idea šŸ¤·šŸ½ā€ā™‚ļø

1

u/[deleted] Dec 16 '23

What are you asking specifically? Please format the code properly

1

u/P-Jean Dec 16 '23

Are you trying to compute the overlap of the two sets? The easiest way to check your algorithm is to print the comparisons as the loops execute for a known and small data set. I’m assuming the second loop is nested?

1

u/TomanHumato46 Dec 18 '23

the sequences in python start counting from 0, so range(4), for example goes through 0,1,2,3.