Closed Thread
Results 1 to 2 of 2

Thread: [SOLVED] Find string in array

  1. #1
    mevets's Avatar
    mevets is offline Newbie
    Join Date
    Nov 2006
    Posts
    11
    Rep Power
    0

    [SOLVED] Find string in array

    [Solved] - I have an array of all the days off the week. I also have a var with the name of the current day written like "Tuesday". How do I search the array of days for my current day and get an integer returned speaking to where the instance is.
    Code:
    now = datetime.datetime.now()
    curDay = now.strftime("%A")
    weekDays = ("Monday", "Tuesday", "Wednesday", "Thurday", "Friday", "Saturday", "Sunday")
    intDay = # this where I would search for curDay in weekDays
    cmbDay.set_active(intDay) # set the combo to the current day
    Last edited by mevets; 10-09-2007 at 07:39 PM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    mevets's Avatar
    mevets is offline Newbie
    Join Date
    Nov 2006
    Posts
    11
    Rep Power
    0
    Quote Originally Posted by mevets View Post
    I have an array of all the days off the week. I also have a var with the name of the current day written like "Tuesday". How do I search the array of days for my current day and get an integer returned speaking to where the instance is.
    Code:
    now = datetime.datetime.now()
    curDay = now.strftime("%A")
    weekDays = ("Monday", "Tuesday", "Wednesday", "Thurday", "Friday", "Saturday", "Sunday")
    intDay = # this where I would search for curDay in weekDays
    cmbDay.set_active(intDay) # set the combo to the current day
    I had to change
    Code:
    weekDays = ("Monday", "Tuesday", "Wednesday", "Thurday", "Friday", "Saturday", "Sunday")
    to
    Code:
    weekDays = ["Monday", "Tuesday", "Wednesday", "Thurday", "Friday", "Saturday", "Sunday"]
    and to find where the day was in the array of days I
    Code:
    weekDays.index(curDay)
    So hard to find on google

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 10-14-2011, 04:34 PM
  2. [SOLVED] Putting togheder an string and an int?
    By Samuka97 in forum C and C++
    Replies: 10
    Last Post: 10-31-2010, 06:07 PM
  3. Export Array Contents in String Then Read Into Array Later
    By rsnider19 in forum PHP Development
    Replies: 3
    Last Post: 08-20-2010, 02:31 AM
  4. Replies: 1
    Last Post: 06-04-2010, 06:13 PM
  5. find a string
    By fazla in forum C and C++
    Replies: 3
    Last Post: 05-28-2010, 08:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts