A string is an extract of text used in a program. This text can be displayed as an output, but it can also be taken from the user as an input. A string is considered to be everything that is written between quotation marks. For example: “House”, “car”, “Anna”, “187.0”, “+”, “.”, etc.

       Yes, punctuation marks, numbers, and even symbols as considered to be strings if they are written between quotation marks. To explain this more efficiently, you can see the following code in which a pair of numbers are considered as strings.


      This is what happens when you run it:


       As you can see, the program was expected to out the sum of x plus y, not to output the text “x+y”. This happened because we typed the function between quotation marks.
        When you want to get a number as an input, you need to place the word “float” or “int” before “input” so the computer knows what type of input is being taken:

X=float(input(“Give me a number”))
Y=int(input(“Give me another number”))
       Just like this, we can type “str” before the word “input” but it is not necessary. Whenever you set an input without placing any word before it, the computer automatically assumes it should be considered as a string. But in case you want to type it anyway, this is how you do it:

X=str(input(“What´s your name?”))

CC BY 4.0 Creation and Use of Strings by Frida Diaz is licensed under a Creative Commons Attribution 4.0 International License.