Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Python programs

Python | Create multiple copies of a string by using multiplication operator



Here, we are going to learn how to create multiple copies of a string by using multiplication operator in Python?
Submitted by IncludeHelp, on September 06, 2018

Given a string and we have to create its multiple copies by using multiplication operator in Python?

If you want to create multiple copies of string, the multiplication operator (*) can be used.

Consider the example – to create N copies of a string

Example:

Input:
str1 = "Hello"
n = 3 

logic:
str2 =str1*3

Output:
str2= "HelloHelloHello"

Program:

# Python program to create N copies 
# of a given string 

# define inputs: string and N 
str1 = "Hello"
n = 3

# create copies 
str2 = str1 * 3 

# print
print "str1: ", str1 
print "str2: ", str2

Output

str1:  Hello
str2:  HelloHelloHello





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.