int(input("Please enter number ",num,":")
I want it to output as: "Please enter number (num): " #no spaces between '(num)' and ':'
When I try to use sep='', i get an error that I can't use that within and input().
int(input("Please enter number ",num,":")
I want it to output as: "Please enter number (num): " #no spaces between '(num)' and ':'
When I try to use sep='', i get an error that I can't use that within and input().
You can us old style % formatting, .format() or use f-strings (python 3.6+) to format your text:
num = 42
tmp = int(input( "Please enter number %s:" % num))
tmp = int(input( "Please enter number {}:".format(num)))
tmp = int(input( f"Please enter number {num}:"))
Output (trice):
Please enter number 42:
See
You should use string formatting to construct the string yourself.
Either using .format
num = 5
int(input("Please enter number {}:".format(num)))
Or using f-strings
for python 3.6+
num = 5
int(input(f"Please enter number {num}:"))
#Output:
Please enter number 5: