Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Python

Python Discussion forum for Python, a high-level language with simple syntax, but yet powerful.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-09-2007, 10:26 PM
mevets's Avatar   
mevets mevets is offline
Newbie
 
Join Date: Nov 2006
Posts: 11
Rep Power: 0
mevets is on a distinguished road
Default [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
__________________
Steve M.

Last edited by mevets; 10-09-2007 at 10:39 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 10-09-2007, 10:38 PM
mevets's Avatar   
mevets mevets is offline
Newbie
 
Join Date: Nov 2006
Posts: 11
Rep Power: 0
mevets is on a distinguished road
Default

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
__________________
Steve M.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Usage of array structures to increment letter instances of text Yuriy M C and C++ 2 09-13-2007 11:49 AM
fread into array position kenna C and C++ 0 08-17-2007 09:03 AM
Python 2D array question annannienann Python 3 04-23-2007 05:36 PM
Is string in array? smith Perl 2 02-14-2007 02:30 PM
Accessing a string by array Saint C# Programming 3 10-03-2006 08:33 PM


All times are GMT -5. The time now is 08:09 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads