Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ew Tools Education 10. Impleme.. Terminal func.py x test.py func.py name.py Collapse E2: Writing an If-Else-Statement A function to extract names from e-mail addresses. W

image text in transcribed
ew Tools Education 10. Impleme.. Terminal func.py x test.py func.py name.py Collapse E2: Writing an If-Else-Statement A function to extract names from e-mail addresses. W N 10. Implement the Function 4 Author: Mobolaji Ogunrinde Read the specification for the function and look at the test cases in the Date: 109/30/2021 6 provided test script. With this information, complete the function, making 7 import introcs sure to use an if-else statement. As there are only two possible types of e- 8 mail addresses, it should be pretty straightforward to figure out how to 9 do this. 10 def extract_name (s) : 11 The harder part is figuring out how to extract the name. This obviously 12 Returns the first name of the person in e-mail address involves string slicing, but you need to know where to slice. There are 13 functions in the introcs| module that can help you here. 14 We assume (see the precondition below) that the e-mail 15 v two forms : When you have implemented the function, run the test script. If you have 16 done it correctly, you should pass all tests. 17 last. first@megacorp. com Check the Function 18 First. last@mompop . net You may run this test multiple times. 19 20 where first and last correspond to the person's first Check It! 21 are not empty, and contain only letters. Everything af 22 to be exactly as shown. AST RUN on 9/30/2021, 7:40:19 PM 23 24 The function preserves the capitalization of the e-mai The call extract_name( ' smith. john@megacorp. com' ) returns None, 25 not ' john' . 26 Examples : 27 extract_name ( ' smith . john@megacorp. com' ) returns 'j 28 extract_name ( ' maggie . white@mompop . net' ) returns 'm 29 extract_name ( ' Bob . Bird@mompop. net' ) returns 'Bob' 30 Next 31 Parameter s: The e-mail address to extract from 32 Precondition: s is in one of the two address formats d 33 34 # You must use an if-else statement in this function. 35 36 first_name = 37 AK 0% (1:0) Python MacBook Pro

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

The emancipation proclamation issued?

Answered: 1 week ago

Question

What war was declared by James Madison ?

Answered: 1 week ago

Question

Americas first sub way system open ?

Answered: 1 week ago

Question

Which was the first president not to own slaves ?

Answered: 1 week ago

Question

Explain about Data Structures in Detail and explain about arrays?

Answered: 1 week ago