Write a simple python program to take input from user calculate it's the length and print it in abbreviation form with a full stop after each character. For example, if the user inputs his name as abc then the output produced have to be a . b . c . # The required output format is as- Please input your name your name is 3 characters long a . b . c .
Answers
Answered by
0
Program 1 (Using list and join functions directly):
string = list(input())
print(' . '.join(string)+' . ')
Explanation:
input() takes a string as an input and it is furtherly converted into a list by splitting each letter in it as an element.
As in, the first statement turns 'abc' into ['a', 'b', 'c']
Then, join() joins each element in the list with the string mentioned i.e., ' . ' in between.
So, ' . '.join(string) makes ['a', 'b', 'c'] to a . b . c and we add ' . ' at the end in default, making the string a . b . c .
Program 2 (Using loop):
string=input()
for i in string:
print(i, end=" . ")
Learn more:
1) Printing all the palindromes formed by a palindrome word.
brainly.in/question/19151384
2) Indentation is must in python. Know more about it at :
brainly.in/question/17731168
Similar questions