3 Replies - 2077 Views - Last Post: 05 May 2014 - 06:14 AM Rate Topic: -----

#1 StumpPNW   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 14-April 14

Input cursor on same line as print statement?

Posted 25 April 2014 - 08:20 PM

Here's some code I have for a simple program to find out how much money I have. It runs just fine except for one small thing that just looks bad.

When I run the program and the print statement asks for the number coins, it then goes to the next line for the users input. How can I make it so the input cursor for the user is on the same line as the print statement?
Hopefully that makes sense.

Here's the part of the code that matters:

#print statement to ask for kind of coin 
    print("What is coin #",x,"? (Enter q for quarter, d for dime, n for nickel, p for penny): ")

#prompting user for input asked for in print statement
    coin_kind=input()



It prints:
[
How many coins do you have? 1
What is the coin # 1 ? (Enter q for quarter, d for dime, n for nickel, p for penny):

]
So when I enter "q" or "d" or whatever, I want to enter it following that second line ending with the colon, not the next line down.
Thank you,

Aaron

Is This A Good Question/Topic? 0
  • +

Replies To: Input cursor on same line as print statement?

#2 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 3000
  • View blog
  • Posts: 11,549
  • Joined: 03-December 12

Re: Input cursor on same line as print statement?

Posted 25 April 2014 - 10:00 PM

Instead of usi.g print() use input.

String = input('Enter q for quarter, d for dime, n for nickel, p for penny: ')


Was This Post Helpful? 0
  • +
  • -

#3 StumpPNW   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 14-April 14

Re: Input cursor on same line as print statement?

Posted 25 April 2014 - 11:51 PM

Thanks! I ended up using end=" "
Was This Post Helpful? 0
  • +
  • -

#4 alexr1090   User is offline

  • D.I.C Head
  • member icon

Reputation: 44
  • View blog
  • Posts: 126
  • Joined: 08-May 11

Re: Input cursor on same line as print statement?

Posted 05 May 2014 - 06:14 AM

Quote

Here's some code I have for a simple program to find out how much money I have. It runs just fine except for one small thing that just looks bad.


That small thing that looks bad on my program to keep track of my money is the amount of money it calculates I have left to spend.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1