How to print input string three times in python?
For suppose
input: Hello
output: Hello Hello Hello
Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Ramya
Here is the program to print the given input string three times in a single line separated by spaces in python. Before going to code this program, let understand what is meant by a string.
A string is the sequence of Unicode characters wrapped inside single, double, or triple quotes. For example “123”, “Hello”, etc…
step -1::Â we need to take the input from the user and store that in a particular variable.
a = input()
step-2:: Now we have to do string concatenation to print the particular string three times and store that concatenated string in a particular variable. for supposing let the variable is “b”,So
b =Â a+a+a
step-3:: Now we have to separate each string with space. For that, we have to give space after every string in python. for that, we need to concatenate the space.
b = a+” “+a+” “+a
step-4:: Now print “b”.
Code:
a = input()
b = a + ” ” + a + ” ” + a
print(b).
word=input()
num=int(input())
result=(word+(” “))*num
print(result)
num = input()
first_digit = num[0]
second_digit =num[1]
reversed_number = second_digit + first_digit
print(reversed_number)
Problem ; input:= Shiva
Sol :=
a = input()
b = (a + ” “) * 3
output:= Shiva Shiva Shiva
a = input()
print(a +” “+ a+” “+ a)