Question: I have the below code for a Python Soundex System code. It works well accept there are two paramaters i have not met I ahve

I have the below code for a Python Soundex System code. It works well accept there are two paramaters i have not met

I ahve been trying for two days and have come up with the below but I need the code to:

1) If two or more letters have been replaced by the same number were next to each othe in the origional full word, keep only the first of them

2) If i have fewer than 4 characters, add zeros to the end to make it a length of 4 ( i am trying the len operator but not getting it right)

surname = input("Please enter surname:") outstring = "" times=0 outstring = outstring + surname[0] #keeps the first letter

for nextletter in surname[1:]:#output the next letter and the rest of the name #while times !=3: if nextletter in ['B','F','P','V','b','f','p','v']: outstring += '1'

elif nextletter in ['C','G','J','K','Q','S','X','Z''c','g','j','k','q','s','x','z']: outstring += '2'

elif nextletter in ['D','T','d','t']: outstring += '3'

elif nextletter in ['L','l']: outstring += '4'

elif nextletter in ['M','N','m','n']: outstring += '5'

elif nextletter in ['R','r']: outstring += '6'

elif nextletter in ['A','E','I','O','U','H','Y','W']: continue times += 1 if times == 3: break

#else:

print (outstring)

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!