Amazon Interview Question
InternsCountry: United States
Interview Type: Phone Interview
dicts=['a','b','c','d']
def stringcompile(text):
bools=False
for i in range(0,len(text)):
c=text[i]
if(c in dicts):
bools=True
else:
bools=False
break
return bools
def modify_text(texts):
word=''
for i in range(0,len(texts)):
c=texts[i]
if(c in dicts):
word=word+c
else:
word=word+'_'
return word
def mainprog(test):
if(stringcompile(test)==True):
print(test)
elif(stringcompile(test)==False):
modify_text(test)
t=input('Enter the string u want to enter ')
mainprog(t)
- Anonymous January 01, 2018