sentence='There is a sun in the mouse hole.'
i=len(sentence)-1
while i >= 0 :
if sentence[i]=='':
print('-')
else:
print('%s'% sentence[i],end='')
i-=1
A space must contain one space between single quotes.
'
<= Blank
'
<= Not blank
Please refer to the code below as well.
sentence='There is a sun in the mouse hole.'
i=len(sentence)-1
while i >= 0 :
if sentence[i]==' ':
print('-',end='')
else:
print('%s'% sentence[i],end='')
i-=1
© 2024 OneMinuteCode. All rights reserved.