- Home
- Premium Memberships
- Lottery Results
- Forums
- Predictions
- Lottery Post Videos
- News
- Search Drawings
- Search Lottery Post
- Lottery Systems
- Lottery Charts
- Lottery Wheels
- Worldwide Jackpots
- Quick Picks
- On This Day in History
- Blogs
- Online Games
- Premium Features
- Contact Us
- Whitelist Lottery Post
- Rules
- Lottery Book Store
- Lottery Post Gift Shop
The time is now 8:08 pm
You last visited
June 3, 2026, 5:36 pm
All times shown are
Eastern Time (GMT-5:00)
Removing 3 Digits With Consecutives In PythonPrev TopicNext Topic
-
I'm trying to figure out how to remove all 3 digit combinations that have consecutive numbers from a list in Python.
Your advice will be greatly appreciated.
Thanks!
-
Philadelpia/Pennsylvania
United States
Member #2,218
September 1, 2003
6,928 Posts
OnlineList of all pick 3 sets without consecutives:
000 0 0 0 T
111 1 1 1 T
222 2 2 2 T
333 3 3 3 T
444 4 4 4 T
555 5 5 5 T
666 6 6 6 T
777 7 7 7 T
888 8 8 8 T
999 9 9 9 T
002 020 200 0 0 2 D
003 030 300 0 0 3 D
004 040 400 0 0 4 D
005 050 500 0 0 5 D
006 060 600 0 0 6 D
007 070 700 0 0 7 D
008 080 800 0 0 8 D
022 202 220 0 2 2 D
033 303 330 0 3 3 D
044 404 440 0 4 4 D
055 505 550 0 5 5 D
066 606 660 0 6 6 D
077 707 770 0 7 7 D
088 808 880 0 8 8 D
113 131 311 1 1 3 D
114 141 411 1 1 4 D
115 151 511 1 1 5 D
116 161 611 1 1 6 D
117 171 711 1 1 7 D
118 181 811 1 1 8 D
119 191 911 1 1 9 D
133 313 331 1 3 3 D
144 414 441 1 4 4 D
155 515 551 1 5 5 D
166 616 661 1 6 6 D
177 717 771 1 7 7 D
188 818 881 1 8 8 D
199 919 991 1 9 9 D
224 242 422 2 2 4 D
225 252 522 2 2 5 D
226 262 622 2 2 6 D
227 272 722 2 2 7 D
228 282 822 2 2 8 D
229 292 922 2 2 9 D
244 424 442 2 4 4 D
255 525 552 2 5 5 D
266 626 662 2 6 6 D
277 727 772 2 7 7 D
288 828 882 2 8 8 D
299 929 992 2 9 9 D
335 353 533 3 3 5 D
336 363 633 3 3 6 D
337 373 733 3 3 7 D
338 383 833 3 3 8 D
339 393 933 3 3 9 D
355 535 553 3 5 5 D
366 636 663 3 6 6 D
377 737 773 3 7 7 D
388 838 883 3 8 8 D
399 939 993 3 9 9 D
446 464 644 4 4 6 D
447 474 744 4 4 7 D
448 484 844 4 4 8 D
449 494 944 4 4 9 D
466 646 664 4 6 6 D
477 747 774 4 7 7 D
488 848 884 4 8 8 D
499 949 994 4 9 9 D
557 575 755 5 5 7 D
558 585 855 5 5 8 D
559 595 955 5 5 9 D
577 757 775 5 7 7 D
588 858 885 5 8 8 D
599 959 995 5 9 9 D
668 686 866 6 6 8 D
669 696 966 6 6 9 D
688 868 886 6 8 8 D
699 969 996 6 9 9 D
779 797 977 7 7 9 D
799 979 997 7 9 9 D
024 042 204 240 402 420 0 2 4 S
025 052 205 250 502 520 0 2 5 S
026 062 206 260 602 620 0 2 6 S
027 072 207 270 702 720 0 2 7 S
028 082 208 280 802 820 0 2 8 S
029 092 209 290 902 920 0 2 9 S
035 053 305 350 503 530 0 3 5 S
036 063 306 360 603 630 0 3 6 S
037 073 307 370 703 730 0 3 7 S
038 083 308 380 803 830 0 3 8 S
039 093 309 390 903 930 0 3 9 S
046 064 406 460 604 640 0 4 6 S
047 074 407 470 704 740 0 4 7 S
048 084 408 480 804 840 0 4 8 S
049 094 409 490 904 940 0 4 9 S
057 075 507 570 705 750 0 5 7 S
058 085 508 580 805 850 0 5 8 S
059 095 509 590 905 950 0 5 9 S
068 086 608 680 806 860 0 6 8 S
069 096 609 690 906 960 0 6 9 S
079 097 709 790 907 970 0 7 9 S
135 153 315 351 513 531 1 3 5 S
136 163 316 361 613 631 1 3 6 S
137 173 317 371 713 731 1 3 7 S
138 183 318 381 813 831 1 3 8 S
139 193 319 391 913 931 1 3 9 S
146 164 416 461 614 641 1 4 6 S
147 174 417 471 714 741 1 4 7 S
148 184 418 481 814 841 1 4 8 S
149 194 419 491 914 941 1 4 9 S
157 175 517 571 715 751 1 5 7 S
158 185 518 581 815 851 1 5 8 S
159 195 519 591 915 951 1 5 9 S
168 186 618 681 816 861 1 6 8 S
169 196 619 691 916 961 1 6 9 S
179 197 719 791 917 971 1 7 9 S
246 264 426 462 624 642 2 4 6 S
247 274 427 472 724 742 2 4 7 S
248 284 428 482 824 842 2 4 8 S
249 294 429 492 924 942 2 4 9 S
257 275 527 572 725 752 2 5 7 S
258 285 528 582 825 852 2 5 8 S
259 295 529 592 925 952 2 5 9 S
268 286 628 682 826 862 2 6 8 S
269 296 629 692 926 962 2 6 9 S
279 297 729 792 927 972 2 7 9 S
357 375 537 573 735 753 3 5 7 S
358 385 538 583 835 853 3 5 8 S
359 395 539 593 935 953 3 5 9 S
368 386 638 683 836 863 3 6 8 S
369 396 639 693 936 963 3 6 9 S
379 397 739 793 937 973 3 7 9 S
468 486 648 684 846 864 4 6 8 S
469 496 649 694 946 964 4 6 9 S
479 497 749 794 947 974 4 7 9 S
579 597 759 795 957 975 5 7 9 SList of all pick 3 with consecutives sets:
001 010 100 0 0 1 D
009 090 900 0 0 9 D
011 101 110 0 1 1 D
099 909 990 0 9 9 D
112 121 211 1 1 2 D
122 212 221 1 2 2 D
223 232 322 2 2 3 D
233 323 332 2 3 3 D
334 343 433 3 3 4 D
344 434 443 3 4 4 D
445 454 544 4 4 5 D
455 545 554 4 5 5 D
556 565 655 5 5 6 D
566 656 665 5 6 6 D
667 676 766 6 6 7 D
677 767 776 6 7 7 D
778 787 877 7 7 8 D
788 878 887 7 8 8 D
889 898 988 8 8 9 D
899 989 998 8 9 9 D
013 031 103 130 301 310 0 1 3 S
014 041 104 140 401 410 0 1 4 S
015 051 105 150 501 510 0 1 5 S
016 061 106 160 601 610 0 1 6 S
017 071 107 170 701 710 0 1 7 S
018 081 108 180 801 810 0 1 8 S
019 091 109 190 901 910 0 1 9 S
029 092 209 290 902 920 0 2 9 S
039 093 309 390 903 930 0 3 9 S
049 094 409 490 904 940 0 4 9 S
059 095 509 590 905 950 0 5 9 S
069 096 609 690 906 960 0 6 9 S
079 097 709 790 907 970 0 7 9 S
023 032 203 230 302 320 0 2 3 S
034 043 304 340 403 430 0 3 4 S
045 054 405 450 504 540 0 4 5 S
056 065 506 560 605 650 0 5 6 S
067 076 607 670 706 760 0 6 7 S
078 087 708 780 807 870 0 7 8 S
089 098 809 890 908 980 0 8 9 S
124 142 214 241 412 421 1 2 4 S
125 152 215 251 512 521 1 2 5 S
126 162 216 261 612 621 1 2 6 S
127 172 217 271 712 721 1 2 7 S
128 182 218 281 812 821 1 2 8 S
129 192 219 291 912 921 1 2 9 S
134 143 314 341 413 431 1 3 4 S
145 154 415 451 514 541 1 4 5 S
156 165 516 561 615 651 1 5 6 S
167 176 617 671 716 761 1 6 7 S
178 187 718 781 817 871 1 7 8 S
189 198 819 891 918 981 1 8 9 S
235 253 325 352 523 532 2 3 5 S
236 263 326 362 623 632 2 3 6 S
237 273 327 372 723 732 2 3 7 S
238 283 328 382 823 832 2 3 8 S
239 293 329 392 923 932 2 3 9 S
245 254 425 452 524 542 2 4 5 S
256 265 526 562 625 652 2 5 6 S
267 276 627 672 726 762 2 6 7 S
278 287 728 782 827 872 2 7 8 S
289 298 829 892 928 982 2 8 9 S
346 364 436 463 634 643 3 4 6 S
347 374 437 473 734 743 3 4 7 S
348 384 438 483 834 843 3 4 8 S
349 394 439 493 934 943 3 4 9 S
356 365 536 563 635 653 3 5 6 S
367 376 637 673 736 763 3 6 7 S
378 387 738 783 837 873 3 7 8 S
389 398 839 893 938 983 3 8 9 S
457 475 547 574 745 754 4 5 7 S
458 485 548 584 845 854 4 5 8 S
459 495 549 594 945 954 4 5 9 S
467 476 647 674 746 764 4 6 7 S
478 487 748 784 847 874 4 7 8 S
489 498 849 894 948 984 4 8 9 S
568 586 658 685 856 865 5 6 8 S
569 596 659 695 956 965 5 6 9 S
578 587 758 785 857 875 5 7 8 S
589 598 859 895 958 985 5 8 9 S
679 697 769 796 967 976 6 7 9 S
689 698 869 896 968 986 6 8 9 S
012 021 102 120 201 210 0 1 2 S
123 132 213 231 312 321 1 2 3 S
234 243 324 342 423 432 2 3 4 S
345 354 435 453 534 543 3 4 5 S
456 465 546 564 645 654 4 5 6 S
567 576 657 675 756 765 5 6 7 S
678 687 768 786 867 876 6 7 8 S
789 798 879 897 978 987 7 8 9 S -
Philadelpia/Pennsylvania
United States
Member #2,218
September 1, 2003
6,928 Posts
OnlinePosting this question at Stackoverflow.
-
Here's a step-by-step guide on how to achieve this:
Convert the numbers to strings to easily check for consecutive digits.Check each number to see if it contains consecutive digits.Filter out the numbers that have consecutive digits.
-
Should be a small list, right? (Including both directions]
consecutives = [012, 123, 234, 345, 456, 567, 678, 789, 890, 901, 987, 876, 654, 543, 432, 321, 210, 109]
So set up an iterative function to step through the list of original numbers, using a loop to test if the current combo matches any of the numbers in the list.
If true, do nothing, if false append to a new list. This resulting list should contain everything in the original list minus the consecutive entries.
Something like
mainList = [< your big list of numbers >]
consecutives = [ < the list of consecutives > ]
newList = [] # A new list to hold the results
for combo in mainList:
if combo in consecutives:continue #this skips to the next combo
else:
newList.append(combo)print(newList)
That should do what you are looking to do.
That assumes counting wraparound consecutives like 890 and 901, if sticking to 0 thru 9 you can edit the consecutive list to be smaller.
Have an EXCELlent day!
-
Looks like I missed 098 in the reversed part of the consecutives list.
Have an EXCELlent day!
-
Thank you all very much!
You've been a great help.
