Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
Trouble using "return" in python.
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 11-14-2010, 06:20 AM
kmjt's Avatar
"In order to succeed, you must first be willing to fail."
kmjt Donor Sythe Verified User
 
Join Date: Aug 2009
Location: Canada
Posts: 8,976
St. Patrick's Day 2013 Heidy
Default Trouble using "return" in python.

Here's the question:

Write a program that reads a string from the keyboard containing a date in the form mm/dd/yyyy and prints out the date in the form Month, Date, Year (See samples below). Your main function should handle all input from the user and printing. You should have another function, convertDate that takes the user input as an argument and returns the converted date string when called. Sample output below:

Please enter a date (format:mm/dd/yyyy):02/11/1995
Converted: February, 11, 1995.


I think i'm mostly done however what I don't get is how to take the user as an argument and return the converted date string when called.. as said in the question printing must all be done in the main function.

Here is my code:

Code:
def main():
    date = raw_input("Please enter a date (format: mm/dd/yyyy): ")
    datetest = date.split("/")

    if datetest[0] == "01":
        print "Converted: January,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "02":
        print "Converted: February,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "03":
        print "Converted: March,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "04":
        print "Converted: April,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "05":
        print "Converted: May,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "06":
        print "Converted: June,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "07":
        print "Converted: July,", datetest[1] + ",", datetest[2]
    
    elif datetest[0] == "08":
        print "Converted: August,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "09":
        print "Converted: September,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "10":
        print "Converted: October,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "11":
        print "Converted: November,", datetest[1] + ",", datetest[2]

    elif datetest[0] == "12":
        print "Converted: December,", datetest[1] + ",", datetest[2]

    else:
        print "Invalid date entered."
    
def convertDate():
 

main()
Reply With Quote
  #2  
Old 11-14-2010, 08:27 AM
Newcomer
 
Join Date: Nov 2010
Posts: 12
Default Re: Trouble using "return" in python.

Heres an example

http://mikehershey.com/pastie/view.p...hph57a70YMg6Sb
Reply With Quote
Reply



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 06:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1