Friday, 24 September 2021

Python: concatenate string and integer

By converting the integer to a string, we can concatenate and integer together.

 

concat_string_int.py

age = 18
msg = 'years'

info = str(age) + ' ' + msg

print(info)

 

Output

18 years

 

 

  

Previous                                                    Next                                                    Home

No comments:

Post a Comment