1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Archy [21]
3 years ago
11

The function below takes one parameter: a string (date_string) containing a date in the mm/dd/year format. Complete the function

to return a list containing integers for each of the date components in month, day, year order. For example, if given the string '06/11/1930', your code should return the list [6, 11, 1930].
Computers and Technology
1 answer:
Natalija [7]3 years ago
8 0

Answer:

The solution code is written in Python 3.

  1. def convertDate(date_string):
  2.    date_list = date_string.split("/")
  3.    for i in range(0, len(date_list)):
  4.        date_list[i] = int(date_list[i])
  5.    return date_list  
  6. print(convertDate('06/11/1930'))

Explanation:

Firstly, create a function convertDate() with one parameter, <em>date_string</em>. (Line 1).

Next, use the Python string <em>split()</em> method to split the date string into a list of date components (month, day & year) and assign it to variable <em>date_list</em>. (Line 3) In this case, we use "/" as the separator.

However, all the separated date components in the <em>date_list</em> are still a string. We can use for-loop to traverse through each of the element within the list and convert each of them to integer using Python<em> int() </em>function. (Line 5 - 6)

At last return the final date_list as the output (Line 8)

We can test our function as in Line 11. We shall see the output is as follow:

[6, 11, 1930]

You might be interested in
For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
hram777 [196]

Answer:

b

Explanation:

5 0
3 years ago
a limited-access expressway. A)allows vehicles to enter or exit only at certain place.B) does not permit trucks or buses.C)has n
zepelin [54]
Hello babe I just wanted to say hello
3 0
3 years ago
Ideally, how often should you back up the data on your computer? once an hour, once a day, once a month, once a year. Please hur
Stells [14]

Explanation:

Every month or so

5 0
3 years ago
Read 2 more answers
How did people find the first ever piece of tech?
kirill115 [55]
It's not how the found it, it's how they made it.
3 0
4 years ago
The oldest "computer" is thought to be how old? please help i beggiging 20 points
igomit [66]
The oldest “computer” is2,000 years old.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is a dynamic lot-sizing technique that calculates the order quantity by comparing the carrying cost and t
    10·1 answer
  • What is grid computing? It is distributed computing where autonomous computers perform independent tasks. It is interconnected c
    12·1 answer
  • What technology will examine the current state of a network device before allowing it can to connect to the network and force an
    7·1 answer
  • Name three actions you can perform on an inserted image.
    7·2 answers
  • Which statement accurately compares the Restart at 1 and Continue Numbering features of Word?
    13·2 answers
  • A small amount of memory stored on the central processor for easy access is called
    6·2 answers
  • HELP
    11·1 answer
  • What are some ways you can work with templates? Check all that apply.
    9·2 answers
  • ফাইল ও ফোল্ডারের মধ্যে পার্থক্য কি এবং ৫ টি ইনপুট ডিভাইসের নাম কি​
    7·2 answers
  • The agency that started ARPANET was looking for
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!