Python Forum
Trying to prompt user for 2 inputs on one line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to prompt user for 2 inputs on one line
#3
Can use a loop and collect input in a list.
food_cal = []
for i in range(0,1):
    food_cal.append(input('Food: '))
    food_cal.append((input('Number of Calories: ')))

print('-'*15)
print(f'Food: {food_cal[0]} Number of Calories: {food_cal[1]}')
Output:
λ python input_loop.py Food: Apple Number of Calories: 50 --------------- Food: Apple Number of Calories: 50
Reply


Messages In This Thread
RE: Trying to prompt user for 2 inputs on one line - by snippsat - Sep-15-2019, 04:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Multiple inputs on the same line (beginner) dementshuk 9 2,843 Sep-03-2021, 02:21 PM
Last Post: dementshuk
  Automatic user/password entry on prompt by bash script PBOX_XS4_2001 3 2,823 May-18-2021, 06:42 PM
Last Post: Skaperen
  How to write a response if a user inputs a string horuscope42 3 2,258 Apr-29-2020, 03:39 PM
Last Post: deanhystad
  Perminantly saving user inputs + being able to retrieve it ThatOneGuyNoOneKnowsCodes 1 1,942 Oct-23-2019, 11:28 PM
Last Post: DT2000
  user inputs in constructing a dictionary Exsul 3 3,717 Apr-10-2019, 12:25 PM
Last Post: ichabod801
  unit testing a method that asks two user inputs() in console gebel 0 2,163 Apr-03-2019, 07:59 PM
Last Post: gebel
  question regarding user Inputs cibb 10 7,277 Apr-04-2017, 03:34 AM
Last Post: alicarlos13
  code that takes inputs for user name amounts etc and then sends custom message shaumyabrata 5 5,353 Feb-12-2017, 11:37 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020