0

What is wrong with code ? Project 4.2 line them up

x=input() for c in x: if c==x: continue print (c*(int(x.index(c))+1)) Input: awesome Expected Output: a ww eee ssss ooooo mmmmmm eeeeeee Getting output except last line

29th Jun 2021, 10:23 PM
Zahed Shaikh
Zahed Shaikh - avatar
3 odpowiedzi
+ 3
x = input() for i, c in enumerate(x): print(c*(i+1))
29th Jun 2021, 10:30 PM
visph
visph - avatar
0
your code get first index of current char... as e occurs twice in 'awesome', second 'e' don't get the expected index ;P
29th Jun 2021, 10:31 PM
visph
visph - avatar
0
#This will work str = input() i=1 for element in str: print(element*i) i=i+1
6th Sep 2021, 1:15 PM
Rushikesh S. Kalkar
Rushikesh S. Kalkar - avatar