I'm rather new to programming, I'm trying to create a program that inputs your name and then prints something like print(user_valu e)"Have a good day").
How do I print a variable value into a string
Collapse
X
-
Following will print the string which you want using simple + operator for concatenating string :
Code:name=input('Enter your name : ') print(name+' Have a good day')
If you don’t want a separator, then use join() function with an empty string.
Using Join() function, the code is following :
Code:print("".join([name]),'Have a good day')
Comment
-
Here is a oneliner code that you can use
Code:print("Welcome {}, have a nice day!! ".format(input()))
In case you want to save the name , use this code
Code:name=input() print("Welcome {}, have a nice day!! ".format(name))
Comment
Comment