### Thread: Newbie - combine 2 sets of input

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jan 2013
Posts
2
Rep Power
0

#### Newbie - combine 2 sets of input

I'm new and I've been trying to figure if I have a user input two sets of input; food up to 10 then another drinks.

first set user input
hot dog, hamburger, pizza (up to 10)

second set user input
coke, 7up, sprite, (up to 10)

How can I make output to

1 - hot dog and coke
2 -hot dog and 7up
3 - hot dog and sprite
...then
4 - hamburger and coke
5 - hamburger and 7 up
6 - hamburger and sprite

so on and so on.....

Is there an easier way to script then the following? Also if there's wasn't any input of 10 food or 10 drinks?

food1 = input('Enter food1: ')
food2 = input('Enter food2: ')
food3 = input('Enter food3: ')
food4 = input('Enter food4: ')
food5 = input('Enter food5: ')
food6 = input('Enter food6: ')
food7 = input('Enter food7: ')
food8 = input('Enter food8: ')
food9 = input('Enter food9: ')
food10 = input('Enter food10: ')

drink1 = input('Enter drink1: ')
drink2 = input('Enter drink2: ')
drink3 = input('Enter drink3: ')
drink4 = input('Enter drink4: ')
drink5 = input('Enter drink5: ')
drink6 = input('Enter drink6: ')
drink7 = input('Enter drink7: ')
drink8 = input('Enter drink8: ')
drink9 = input('Enter drink9: ')
drink10 = input('Enter drink10: ')

print(food1, drink1)
print(food1, drink2)
print(food1, drink3)
print(food1, drink4)
print(food1, drink5)
print(food1, drink6)
print(food1, drink7)
print(food1, drink8)
print(food1, drink9)
print(food1, drink10)
print(food2, drink1)
print(food2, drink2)
print(food2, drink3)
print(food2, drink4)
print(food2, drink5)
print(food2, drink6)
print(food2, drink7)
print(food2, drink8)
print(food2, drink9)
print(food2, drink10)
Thanks!
2. Code:
```# python3

# loops, lists, and string formatting will help considerably.
# We'll cover functions next week.

food = list()
drink = list()

print('Note: enter a blank line to progress')

i = 0
edible = 'food'
L = food

while True: # repeat block of statements forever
i += 1  # increment i
prompt = 'Enter {}{}: '.format(edible,i)
s = input(prompt)
s = s.strip()
if not s:  # leave the while loop on blank line
break
L.append(s)

print()

i = 0
edible = 'drink'
L = drink

while True: # repeat block of statements forever
i += 1  # increment i
prompt = 'Enter {}{}: '.format(edible,i)
s = input(prompt)
s = s.strip()
if not s:  # leave the while loop on blank line
break
L.append(s)

print('\n\nmeal matrix')

for f in food:
print()
for d in drink:
print('{} and {}'.format(f,d))```
program run example:
Code:
```\$ python3 p.py
Note: enter a blank line to progress
Enter food1: dog
Enter food2: chili
Enter food3: worms
Enter food4:

Enter drink1: 7 up
Enter drink2: tequilla
Enter drink3:

meal matrix

dog and 7 up
dog and tequilla

chili and 7 up
chili and tequilla

worms and 7 up
worms and tequilla```
Please observe the two while loops are identical. They behave differently because I assigned different values to the variables used within the block before starting the while loop.

• anthony415 agrees
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jan 2013
Posts
2
Rep Power
0
Thanks!

One more question:
What if I use html for the input then submit the values to the py and use the form.getvalue for the food and drink?
4. In that case post the html page description and have someone other than me answer.