Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Python

Unregistered, Check out the Coder Battles in the Announcement and Game forums.

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, 09:26 PM
mevets's Avatar   
mevets mevets is offline
Newbie
 
Join Date: Nov 2006
Posts: 11
Credits: 0
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 09: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, 09:38 PM
mevets's Avatar   
mevets mevets is offline
Newbie
 
Join Date: Nov 2006
Posts: 11
Credits: 0
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

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 10:49 AM
fread into array position kenna C and C++ 0 08-17-2007 08:03 AM
Python 2D array question annannienann Python 3 04-23-2007 04:36 PM
Is string in array? smith Perl 2 02-14-2007 01:30 PM
Accessing a string by array Saint C# Programming 3 10-03-2006 07:33 PM


All times are GMT -5. The time now is 05:04 AM.

Contest Stats

Xav ........ 1097.16
MeTh0Dz|Reb0rn ........ 986.37
morefood2001 ........ 850.04
John ........ 841.93
WingedPanther ........ 684.54
marwex89 ........ 638.26
Brandon W ........ 493.36
chili5 ........ 292.12
Steve.L ........ 188.37
orjan ........ 187.41

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 79%

Ads