string print in python code example

Example 1: how to print something in python

print("whatever you want to print")

Example 2: how to create string in python

string = "this is string"
#or
string = 'this is also string'

Example 3: strings in python

#A string is a type of data. There are many data types. It can be manipulated.
#It can be storerd as a variable
myString = "Hello world"
#WE can print it:
print(myString)
#You can append it to arraY:
myArr = []
myArr.append(myString)
#You can find the index of a character in a string:
H = myString[0]
#You can use methods on it:
lowercase = myString.lower()
#You can convert it into a integer provided it is a numerical string
myInt = int(myString)
#So thats the basics, hope i haven't left anything out.

Example 4: python print

print('Message')

Example 5: print in python

# This prints out the value provided by the user

print("Hello World\n")

Example 6: python string tutorial

print("Hello\nworld") #for a new line "\n"
print("I want to type \"Hello world\" but I can't") #for writing characters used in coding

phrase = "Hello World" #assigning a value
print(phrase) #for printing values

print(phrase.upper()) #for changing the string to upper case. 
# If you change "upper" out with "lower" it will changing the string to lower case.

print(len(phrase)) # printing the length of the string

print(phrase[0]) # giving the first letter of the string
# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

print(phrase.index("e")) # printing where in the string "e" is
print(phrase.index("llo"))# printing where in the string "llo" is