+ 3
I have used some different approach as the ones discussed in dicuss section but I'm not getting the correct answer
I have used some different approach as the ones discussed in dicuss section but I'm not getting the correct answer After going through all the codes input is just getting printed in output too. The code of the program is like this: str=input() splits=str.split() d={0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'} for k in range (len(splits)): for i in d: if splits[k]==i: splits[k]=dict.get(i) print(' '.join(splits)) Link to the program: https://www.sololearn.com/coach/64?ref=app
3 Answers
+ 1
Input is taken string form, so inputed numbers also is in string form, not in Integers. So take dictionary keys as string value like: '0' , '1',...
d={'0':'zero','1':'one','2':'two','3':'three','4':'four','5':'five','6':'six','7':'seven','8':'eight','9':'nine','10':'ten'}
In loop, you mentioned d as dict.. Correct it.
+ 2
Pls post your code here
the link provided by you is the link of the code coach you have to paste the link of your attempt
+ 2
str=input()
splits=str.split()
d={0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'}
for k in range (len(splits)):
for i in d:
if splits[k]==i:
splits[k]=dict.get(i)
print(' '.join(splits))
The code is here