Creating a Variable and Appending it in Python

In this Python tutorial, we will learn how to create a variable in Python and append it. So, at first we will create a variable, and then store some values into it, and after that, we will perform the appending method.

Create a variable in Python

Our goal is to define the variable and then store some values into it. So we will create a variable and then store some values into it.

word='python'

Output:python

Print the Variable’s Values using Addresses – Python

Printing  the entire values by using their address values and getting the output.



print(word[0:6])

Output:

python

Printing the values from start to end and getting the output in the proper manner

print(word[:1])
print(word[:2])
print(word[:3])
print(word[:4])
print(word[:5])
print(word[:6])
Output:
p
py
pyt
pyth
pytho
python

There are other ways also by which we can also print the values like using the negative indexing.

Also read,

Leave a Reply

Your email address will not be published. Required fields are marked *