0
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().

  • Don't count on `input` for formatting, do it your self: `str(num)+":"` will leave no space. – Amadan Mar 07 '19 at 07:22

2 Answers2

1

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

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
0

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:
Paritosh Singh
  • 6,034
  • 2
  • 14
  • 33