# Convert an integer value to the string using str() function in Python

An example of str() function in Python: Here, we are going to learn how to convert a given integer value to the string using str() function in Python?
Submitted by Anuj Singh, on August 08, 2019

Given an integer value and we have to convert the value to the string using str() function.

Python code to convert an integer value to the string value

```# Python code to convert an integer value
# to the string value

# integer value
i_value = 12345

# converting to the string value
s_value = str(i_value)

# printing the integer & string values with their types
print("i_value: ", i_value)
print("type(i_value): ", type(i_value))

print("s_value: ", s_value)
print("type(s_value): ", type(s_value))

# another operation by multiplying the value
print("i_value*4: ", i_value*4)
print("s_value*4: ", s_value*4)
```

Output

```i_value:  12345
type(i_value):  <class 'int'>
s_value:  12345
type(s_value):  <class 'str'>
i_value*4:  49380
s_value*4:  12345123451234512345
```

Code explanation:

In the above code i_value is an integer variable contains an integer value, we are converting i_value to the string by using str() function and storing the result in s_value variable. For further verification of the types – we are printing the types of both variables with their values and also printing their 4 times multiplied value.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates