How to concatenate a string and an integer in Python

2 Answers

0 votes
s = 'value = '

n = 8741

result = s + str(n)

print(result)  

  
    
    
'''
run:
    
value = 8741
    
'''

 



answered Jun 27, 2022 by avibootz
0 votes
s = 'value = '

n = 8741

result = f'{s}{n}'

print(result)  

  
    
    
'''
run:
    
value = 8741
    
'''

 



answered Jun 27, 2022 by avibootz

Related questions

1 answer 194 views
3 answers 239 views
2 answers 205 views
3 answers 269 views
1 answer 159 views
1 answer 147 views
...