Novices vs Practitioners
Which of the following command will return “GL012″?
s = ‘chrZt34500t45000tgeneid=GL012;transcriptID=0001;symbol=XVF’
- s.split(‘=’)[2].split(‘;’)[0]
- s.replace(‘=’, ‘t’).split()[3].split(‘;’)[0]
- s.split(‘t’)[-1].split(‘;’)[0].split(‘=’)[-1]
- s.replace(‘;’, ‘t’, 1).split()[3].split(‘=’)
Assessment
What is the output of the following command:
‘hello,world’.split(‘,’)[1].find(‘h’)
- -1
- 1
- ValueError: substring not found
Exercise
Fill in a right method for each output.
s = ‘John,Michigan,Engineern’
s.___(‘,’) **—>** [‘John’, ‘Michigan’, ‘Engineern’]
s._\_(‘____’, ‘__’) **—>** ‘John,MI,Engineern’
s._() **—>** ‘jOHN,mICHIGAN,eNGINEERn’
s.___ (‘Engine’) —> 14
s._(‘OHIO’) **—>** ValueError: substring not found
s.__(‘OHIO’) —> -1