Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NEED CODE IN PYTHON 4. Write a Python program stored in a file L4q4.py that:that takes a string variable as input from the user and
NEED CODE IN PYTHON
4. Write a Python program stored in a file L4q4.py that:that takes a string variable as input from the user and prints the length of the entry on the next line. If the length of the entry is even, print all the characters that are in the even position. If the length of the entry is odd, print all the characters that are in the odd position. Add an empty line. On the following line, print the index of each character under the corresponding character. Sample output #1: Print one full line of * on line 1. At the prompt, the user enters Texas A&M University (line 2). The program outputs the length of input on line 3 (even). Line 4 is blank and on line 5 all the characters in the even positions are printed. The corresponding index of each character is printed below them on line 6 and one full line of * is printed on line 7. *********** 1. ********************************************** 2. Enter a string variable: Texas A&M University 3. Length of the string Texas A&M University is 20 4. 5. T s A MU i es t 6. O 2 4 6 8 10 12 14 16 18 7. ********* ************** ************** ************************ Sample output #2: Print one full line of * on line 1. At the prompt, the user enters Howdy! Good Luck." (line 2). The program outputs the length of input on line 3 (odd). Line 4 is blank and on line 5 all the characters in even positions are printed. The corresponding index of each character is printed below them on line 6 and one full line of * is printed on line 7. 1. ************* 2. Enter a string variable: Howdy! Good Luck. 3. Length of the string Howdy! Good Luck. is 17 4. 5. 0 d ! o u k 6. 1 3 5 7 9 11 13 15 7. ****** ****************Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started