Answers for "string format() python"

2

Python string formatting

# String Formatting
name1 = 'Andrei'
name2 = 'Sunny'
print(f'Hello there {name1} and {name2}')       # Hello there Andrei and Sunny - Newer way to do things as of python 3.6
print('Hello there {} and {}'.format(name1, name2))# Hello there Andrei and Sunny
print('Hello there %s and %s' %(name1, name2))  # Hello there Andrei and Sunny --> you can also use %d, %f, %r for integers, floats, string representations of objects respectively
Posted by: Guest on November-21-2021
0

python string format

print(f'Hello UseriD: {value}')
Posted by: Guest on March-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language