Question

Convert date format in Python 3 US_to_EU: This function takes a string representing a US style...

Convert date format in Python 3

US_to_EU: This function takes a string representing a US style date and returns a European style date string. US strings have the month first, European strings have the day first. US uses slashes as separators, Europe uses dots. Example calls:

US_to_EU('3/13/18') --> '13.3.18'

US_to_EU('3/13/2018') --> '13.3.2018'

US_to_EU('03/13/2018') --> '13.03.2018'

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:-

def US_to_EU(s): #function
x=s.split("/") #split the time into word by using the '/'
temp=x[0] #swap first two words
x[0]=x[1];
x[1]=temp;
x=".".join(x); #join all words using the '.'
return x # return result

Screenshot of the program:-

Output of the program:-

Add a comment
Know the answer?
Add Answer to:
Convert date format in Python 3 US_to_EU: This function takes a string representing a US style...
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: Write a function called every_other_character() that takes in a string and returns a new...

    Python 3: Write a function called every_other_character() that takes in a string and returns a new string with every other character removed. That is, the new string will include the first, third, fifth, etc. letters of the given string. Must use a while or for loop in the solution.

  • Please use python 3 programming language Write a function that gets a string representing a file...

    Please use python 3 programming language Write a function that gets a string representing a file name and a list. The function writes the content of the list to the file. Each item in the list is written on one line. Name the function WriteList. If all goes well the function returns true, otherwise it returns false. Write another function, RandomRange that takes an integer then it returns a list of length n, where n is an integer passed as...

  • 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

  • python Problem 3 (Palindrome) Write a function called ispalindrome(string) that takes a string (with spaces) as...

    python Problem 3 (Palindrome) Write a function called ispalindrome(string) that takes a string (with spaces) as argument and returns True if that string (ignoring spaces) is a palindrome. A palindrome is a word or phrase that spells the same thing forwards as backwards (ignoring spaces). Your program should use a recursive process to determine the result, by comparing the first and last letters of the string, and if necessary, calling ispalindrome() on the rest of the string. Sample run: print(ispalindrome('never...

  • PYTHON Programming short Questions: 1. Write a function takes as input name (string) and age (number)...

    PYTHON Programming short Questions: 1. Write a function takes as input name (string) and age (number) and prints: My name is <name> and I am <age> years old(where name and age are the inputs) 2. Write a function that takes as input a and b and returns the result of: ??ab 3. Write a function that takes as input a and b and returns the result of: ??ab if it is valid to divide a and b 4. Write a...

  • Implement a Java method named addBinary() that takes two String arguments (each representing a binary value)...

    Implement a Java method named addBinary() that takes two String arguments (each representing a binary value) and returns a new String corresponding to the result of performing binary addition on those arguments. Before you begin, if one of the arguments is shorter than the other, call your pad() method from the previous step to extend it to the desired length. Note: ped() method is public static String pad(String input, int size) { if(input.length()>=size) { return input; } String a =...

  • IN PYTHON 3) Number of Words Write a function numWords() which takes in a string can...

    IN PYTHON 3) Number of Words Write a function numWords() which takes in a string can prints the number of words in the string. You can assume that words will only be separated with spaces, commas, and periods. "hello, world" -> 2 "this is cool" -> 3 4) Is Sorted Write a function isSorted() which takes in an list of integers and returns true if the numbers are sorted from smallest to largest.

  • Program must be in Python 3. Write a program that prompts the user to enter two...

    Program must be in Python 3. Write a program that prompts the user to enter two strings and then displays a message indicating whether or not the first string starts with the second string. Your program must satisfy the following requirements. 1. Your program must include a function called myStartsWith that takes two string parameters. This function returns True if the rst string starts with the second string and returns False otherwise. 2. Your program must include a main function...

  • PYTHON QUESTION 2. Write a function called first_day_greater that takes two lists, L1 and L2 ,...

    PYTHON QUESTION 2. Write a function called first_day_greater that takes two lists, L1 and L2 , representing the daily measured weights of rat 1 and rat 2, respectively, and returns the index of the first day for which the weight for the fist rat is greater than the weight of the second rat.If there are no such days then the function should return -1. You may NOT assume that L1 and L2 are the same length. Use the following to...

  • Write a function in matlab for these parameters (char) A string representing 7 days of the...

    Write a function in matlab for these parameters (char) A string representing 7 days of the week (eg. 'N M T W R F S') (double) A vector representing 7 dates of the week (eg. [4 5 6 8 79 10]) (double) A positive or negative number of days (char) A string representing 7 days of the new week (double) A vector representing 7 dates of the new week circshift() It's fairly simple to determine what the date was or...

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