FREE INTERACTIVE ONLINE COURSE

Python 3

FOR BEGINNERS


"The first Python course that simply amazed me. Very well explained and easy to understand." (Alexandru Cosmin)

"The best Python course in Romania." (Iulian Geană)


ALL REVIEWS
LESSON 8
PAG. 2 / 5
Strings
Home >>> Free Online Lessons, Python 3

Operators + and *

The addition operator "+" serves to join (concatenate) two or more strings.

For two numeric values, the "*" operator represents multiplication. In the case of str operands, it serves to multiply the value (the text).

EXAMPLE
Editor - lesson_8_strings.py
       
Console/Output done
DETAILS

We won't dwell on this aspect too much. Simply put, the "+" operator joins the strings as a result of the operation. We can play with spaces (the blank character), with multiple strings, try it out!

Be mindful of the data type:



Both must be of type str, otherwise you will get an error. The variable n holds an int object, while m holds a str object. Use the conversion str(n)+m!
Run the program then proceed to the next page.
 home   list  CONTENTS   perm_identity   arrow_upward