Hi ,

Kindly assist me with resolving this defect from the testers team. am new to python. the defect is as follows:
"A small code change must be added to checkif the password that has been received from the API call compares to "clear|......". If this is the case then the string must be modified by removing the "clear|" part from the string."

How do i do this. i have the code that needs to be edited.

Regards,
Sepiso.

Recommended Answers

All 2 Replies

Here's a few things to get you on your way:

>>> inp = 'clear|foobar'
>>> inp.find('clear|')
0
>>> inp.rfind('|')
5
>>> inp[5+1 : ]  # This is slicing
'foobar'
>>> inp.split('|')
['clear', 'foobar']
>>> inp.split('|')[1]
'foobar'
>>>

I'd suggest

prefix = "clear|"
if inp[:len(prefix)] == prefix:
    inp = inp[len(prefix):]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.