Question: In python just using if-else can anyone help me to implement function of thi def extract_name(s): Returns the first name of the person in

In python just using if-else can anyone help me to implement function of thi def extract_name(s): """ Returns the first name of the person in e-mail address s. We assume (see the precondition below) that the e-mail address is in one of two forms: last.first@megacorp.com first.last@mompop.net where first and last correspond to the person's first and last name. Names are not empty, and contain only letters. Everything after the @ is guaranteed to be exactly as shown. The function preserves the capitalization of the e-mail address. Examples: extract_name('smith.john@megacorp.com') returns 'john' extract_name('maggie.white@mompop.net') returns 'maggie' extract_name('Bob.Bird@mompop.net') returns 'Bob' Parameter s: The e-mail address to extract from Precondition: s is in one of the two address formats described above """ Right now I have

x =introcs.split(s, ('@'),[0]) y =introcs.split(s, ('@'),[1])

if y =='megacorp.com': a = introcs.split(x, ('.'),[1]) else: a = introcs.split(x, ('.'),[0]) return a But getting this error

The call extract_name('smith.john@megacorp.com') crashed. Traceback (most recent call last): TypeError: 'list' object cannot be interpreted as an integer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!