Python Forum
Checking number in a list to see if they are beside each other
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Checking number in a list to see if they are beside each other
#1
List1 =[2,3,4,9,9,5,1]
def checkList(List1):
    for i in range(len(List1 - 1)):
      
if List1[i] == 9 and List1[i+1] == 9:
            return True
          return false 
i want to check if the number 9 comes b4 any other number in the list but my problem is the code does not return true or false
Reply


Messages In This Thread
Checking number in a list to see if they are beside each other - by Allaye - Aug-25-2019, 09:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Delete strings from a list to create a new only number list Dvdscot 8 1,593 May-01-2023, 09:06 PM
Last Post: deanhystad
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,295 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  Checking if a string contains all or any elements of a list k1llcod3 1 1,140 Jan-29-2023, 04:34 AM
Last Post: deanhystad
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,932 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  Split a number to list and list sum must be number sunny9495 5 2,342 Apr-28-2022, 09:32 AM
Last Post: Dexty
  Divide a number by numbers in a list. Wallen 7 8,105 Feb-12-2022, 01:51 PM
Last Post: deanhystad
  When did the number got included in the list? Frankduc 14 3,163 Feb-03-2022, 03:47 PM
Last Post: Frankduc
  Checking the number of arguments a function takes Chirumer 3 2,195 Jul-06-2021, 04:56 PM
Last Post: Chirumer
  Count number of occurrences of list items in list of tuples t4keheart 1 2,405 Nov-03-2020, 05:37 AM
Last Post: deanhystad
  How do I add a number to every item in a list? john316 2 2,006 Oct-28-2020, 05:29 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020