String Sequential Comparison

Asked 2 weeks ago, Updated 2 weeks ago, 1 views

Hello, I have a question while studying Python.

If there are five list elements (list[0].list[1]), (list[0].list[2]), (list[0].list[3]), (list[0].list[4]), (list[1].list[2]), .....(list[3].[4] I wanted to compare these bound terms. If the number of elements is small, superimpose the if statement to move the preceding number (ex_0,1..)3) You can make a comparative coding statement, but if you have a very large number of elements, you can't think of how to move the first number when you compare.

When I think about my poor coding skills, I'll use the for range statement If it becomes i == b, I thought a = a+1 in the for statement, but I can't think of a way to re-execute the executed for range statement.

I'm not good at speaking, so I'm worried if you'll understand my questions. Please Thank you.

python list

2022-09-20 14:42

1 Answers

I don't know what you're worried about, but... Take it easy.

for month in range(1, 13) :
    for day in range(1, 32) :
        If month! = day : # Skip the case where two numbers are the same
            print("month < day: " + str(month) + ' < ' + str(day) + ' = ' + str(month < day))

2022-09-20 14:42

If you have any answers or tips

© 2022 pinfo. All rights reserved.