Question

Write a program that reads a string from the user containing a date in the form...

Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018  

I am asking for help in basic python please

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def formatLongDate(s):
    lst = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
    values = s.split("/")
    month = lst[int(values[0])-1]
    day = values[1]
    year = "20"+values[2]
    return month+" "+day+", "+year

# Testing
if __name__ == '__main__':
    date = input("Enter date in mm/dd/yyyy form: ")
    print(formatLongDate(date))

Add a comment
Know the answer?
Add Answer to:
Write a program that reads a string from the user containing a date in the form...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python 3. Date Printer Write a program that reads a string from the user containing a...

    Python 3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018 3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018

  • 3. Date Printer Write a program that reads string from the user containing a date in...

    3. Date Printer Write a program that reads string from the user containing a date in the form mm/dd/yyyy. It should print the date in the form March 12, 2014 . ( it is starting out with python third edition ) Can anyone please do it by python program .

  • IN PYTHON, Write a program that reads a string from the user containing a date in...

    IN PYTHON, Write a program that reads a string from the user containing a date in the form mm/dd/ yyyy. It should print the date in the form April 12, 2017. Hint: Get the "mm" from the user entered date "mm/dd/yyyy", then convert the "mm" into a month number. You may use an list month_list = ['January', 'February','March','April', 'May','June', 'July','August', 'September', 'October', 'November', 'December']. Use the month number you got from "mm" to get the month name.

  • Write a program that accepts a date from the user in the form mm/dd/yyyy

    # C PROGRAMMING LANGUAGEWrite a program that accepts a date from the user in the form mm/dd/yyyy and then dis- plays it in the form month dd, yyyy, where month is the name of the month: Enter a date (mm/dd/yyyy): 2/17/2011 You entered the date February 17, 2011 Store the month names in an array that contains pointers to strings.

  • C Program Question 1: Write a program that reads a date from the keyboard and tests...

    C Program Question 1: Write a program that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format: mm/dd/yyyy Note that there is no space in the above format. A date in this format must be entered in one line. A valid...

  • Question 1: Write a program in C that reads a date from the keyboard and tests...

    Question 1: Write a program in C that reads a date from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format: mm/dd/yyyy Note that there is no space in the above format. A date in this format must be entered in one line. A valid...

  • anyString.substr(x, n) - Returns a copy of a substring. The substring is n characters long and...

    anyString.substr(x, n) - Returns a copy of a substring. The substring is n characters long and begins at position x of anyString. Write a program that reads a string from the user containing a date in the format mm/dd/yyyy. You have to use above substring method to extract the various fields from the format. It should print the date in the form Month Date, Year. Validate:  Exit the program with error message as “Invalid date format” if length of...

  • Write a program that prompts the user to enter the date in mm/dd/yyyy format. The program...

    Write a program that prompts the user to enter the date in mm/dd/yyyy format. The program should use a single input statement to accept the date, storing each piece of the date into an appropriate variable. Demonstrate that the input was obtained correctly by outputting the month, day, and year to the screen. Sample output: Enter (date (mm/dd/yyyy): 02/08/2011 Month entered: 2 Day entered: 8 Year entered: 2011 Challenge: Although the user entered 02, C++ drops the 0 as insignificant...

  • Finish the program. Follow the program logic and then complete the algorithm in the function. Use...

    Finish the program. Follow the program logic and then complete the algorithm in the function. Use the programs given constructs and variables only. #include <iostream> #include <string> using namespace std; // Prototype string format(string); int main() { // The following string will hold the user's input. string userDate; // The following string will hold the formatted date. string formattedDate; // Get a date from the user. cout << "Enter a date in the form mm/dd/yyyy: "; cin >> userDate; //...

  • Write a C++ program that determines the user's age after the   user enters both the current...

    Write a C++ program that determines the user's age after the   user enters both the current date and hisher birthdate as 3   integers:                yyyy mm dd                                                                                             Define a class which is named DateType and will be used to     declare 2 objects: "birthday" and "today". The class will have a function "output" which will display the date in conventional form (like it is above next to Date Assigned: Month dd, yyyy and it will have a second function named     “input”...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT