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 195 views
3 answers 241 views
2 answers 206 views
3 answers 270 views
1 answer 160 views
1 answer 148 views
...