0

def modify_last(txt, n): s=txt[:] d=txt[-1]*n s,d=gather return "".join(gather) modify_last("Hello", 3) #➞ "Hello

How can I repeat the last index of string by number (n)? Does my code works well .forget the indentation

9th Oct 2020, 12:20 PM
ÄKoderj
5 ответов
+ 2
You should first replace that actual code and question with each other for readability ,and use python and string as separate tags
9th Oct 2020, 12:38 PM
Abhay
Abhay - avatar
+ 2
Your code works well ,so what is the actual error you are getting?
9th Oct 2020, 12:42 PM
Abhay
Abhay - avatar
+ 1
Actully its working but in sublime it says error
9th Oct 2020, 12:48 PM
ÄKoderj
+ 1
jäbbar then you should have mentioned the actual issue ,I have no idea about working with sublime so can't help further ,sorry , hopefully someone else can assist you
9th Oct 2020, 12:49 PM
Abhay
Abhay - avatar
0
I have another question #Abhay I have a dictionary with keys of string and once the input is key (string) I want output numbers Here is sample print("one") output 1 hopefully its clear
9th Oct 2020, 12:50 PM
ÄKoderj