Here is my code below if i print it directly i'm not getting any brackets or commas whereas if i store it in a variable and print the variable its getting printed in brackets.
If anyone know to print it without brackets please let me know
Code:
user_name = input('Your Name')
user_year = int(input('Your Birth Year'))
user_age = 2021 - user_year
user_info = "Age of",user_name,"is",user_age
print(user_info)
print('Age of',user_name,'is',user_age)
Output:
Your Name Sri Govind
Your Birth Year 2005
('Age of', ' Sri Govind', 'is', 16)
Age of Sri Govind is 16
Process finished with exit code 0
Inputting the value of the variables in the string is straightforward.
user_info = "Age of {name} is {age}".format(name=user_name, age=user_age)
user_info = f"Age of {user_name} is {user_age}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With