Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions