Inputs and Outputs Basics
Inputs and Outputs Basics Take Input From User input() allows flexibility to take the input from the user. Reads a line of input as a string. Code 1 2 username = input ( ) print ( username ) PYTHON Input Ajay Output Ajay Working with Strings String Concatenation Joining strings together is called string concatenation. Code 1 2 a = "Hello" + " " + "World" print ( a ) PYTHON Output Hello World Concatenation Errors String Concatenation is possible only with strings. Code 1 2 a = "*" + 10 print ( a ) PYTHON Output File "main.py", line 1 a = "*" + 10 ^ TypeError: can only concatenate str (not "int") to str String Repetition * operator is used for repeating strings any number of times as required. Code 1 2 a = "*" * 10 print ( a ) PYTHON Output ********** Code 1 2 3 s = "Python" s = ( "* " * 3 ) + s + ( " *" * 3 ) print ( s ) PYTHON Output * * ...