Jump to content

Hello,

This is my code currently, which is really close to completing:

tops=[]
tops2=[]
top=input('Topping: ')
tops2.append(top)
while top != '':
  tops.append(top)
  top2=input('Topping: ')
  if top2 in tops:
    print('Got that already! ')
  top=top2  
  if top2 not in tops:
    if top == '':
      tops2.append(top)
print(', '.join(tops2))
 
It should produce this:
 
Topping: olives
Topping: zucchini
Topping: tomato
Topping: olives
Got that already!
Topping: artichokes
Topping: 
olives, zucchini, tomato, artichokes
 
It nearly works but only prints out one of the toppings at the end:
 
Topping: olives
Topping: zuchini
Topping: olives
Got that already! 
Topping: 
olives
 
 

 

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/
Share on other sites

Link to post
Share on other sites

Sorry, this has nothing to do with that. I just had to say, what an amazing rig you have there!

        | CPU: Intel Core i3 4130 | GPU: PowerColor R9 270 | Motherboard: Asrock H81M-HDS | RAM: Kingston HyperX Fury 4GB |

 

|HDD: Western Digital 1TB | Case: NZXT Source 210 | PSU: Corsair CX430W | 

 

 

| Mic: Blue Snowball iCE | Mouse: Corsair K65 RGB | Keyboard: Razer Blackwidow Chroma |

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2853371
Share on other sites

Link to post
Share on other sites

Sorry, this has nothing to do with that. I just had to say, what an amazing rig you have there!

The current one?

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2853376
Share on other sites

Link to post
Share on other sites

Sorry, this has nothing to do with that. I just had to say, what an amazing rig you have t

The one you have in the sig with two titans. quiet a beast compared to my i3 xD

        | CPU: Intel Core i3 4130 | GPU: PowerColor R9 270 | Motherboard: Asrock H81M-HDS | RAM: Kingston HyperX Fury 4GB |

 

|HDD: Western Digital 1TB | Case: NZXT Source 210 | PSU: Corsair CX430W | 

 

 

| Mic: Blue Snowball iCE | Mouse: Corsair K65 RGB | Keyboard: Razer Blackwidow Chroma |

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2853381
Share on other sites

Link to post
Share on other sites

epic quote fail...

        | CPU: Intel Core i3 4130 | GPU: PowerColor R9 270 | Motherboard: Asrock H81M-HDS | RAM: Kingston HyperX Fury 4GB |

 

|HDD: Western Digital 1TB | Case: NZXT Source 210 | PSU: Corsair CX430W | 

 

 

| Mic: Blue Snowball iCE | Mouse: Corsair K65 RGB | Keyboard: Razer Blackwidow Chroma |

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2853384
Share on other sites

Link to post
Share on other sites

I think this is what you wanted...

toppings = []while 1:    topping = raw_input("Topping: ")    if(topping == ''):        break    if topping in toppings:        print "Got that already!"    else:        toppings.append(topping)if len(toppings)>0:    print "Toppings:",    for i in range(0,len(toppings)-1):        print toppings[i] + ",",    print toppings[-1]else:    print "You didn't enter anything"

There's probably a better way of printing them out but its the weekend and my brain shutsdown

That's, so close. How would I print the ingredients on one line instead of on a separate line. 

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2854539
Share on other sites

Link to post
Share on other sites

Using that I seem to get them on 1 line

 

Topping: potato

Topping: cheese

Topping: cheese

Got that already!

Topping: apple

Topping:

Toppings: potato, cheese, apple

Topping: Potato
Topping: cheese
Topping: cheese
Got that already!
Topping: apple
Topping: 
Topping:
Potato,
cheese,
apple
 
I get this. 

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2854649
Share on other sites

Link to post
Share on other sites

 

Try this then..

toppings =[]while 1:    topping = raw_input("Topping: ")    if(topping == ''):        break    if topping in toppings:        print "Got that already!"    else:        toppings.append(topping)if len(toppings)>0:    message = "Toppings: "    for i in range(0,len(toppings)-1):        message += toppings[i] + ", "    print message + toppings[-1]else:    print "You didn't enter anything"

Hmmm,

I get this now:

Topping: Olives
Topping: Zucchini
Topping: Tomato
Topping: Olives
Got that already!
Topping: Artichokes
Topping: 
Olives, Artichokes
 
It should be like this, but as you can see Tomato and Zucchini hasn't been printed. 
 
 
 
This is the code I'm using:
toppings =[]
while 1:
    topping = input("Topping: ")
    if(topping == ''):
        break
    if topping in toppings:
        print ("Got that already!")
    else:
        toppings.append(topping)
if len(toppings)>0:
    message = ("Topping: ")
    for i in range(0,len(toppings)-1):
        message = toppings[i] + ", "
    print (message + toppings[-1])
 
I adjusted it to work with the program.

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2854710
Share on other sites

Link to post
Share on other sites

Took me a while to see it, but in your code

                       message = toppings[i] + ", "

should be

                       message += toppings[i] + ", "

Thank you for all your help,

Last thing

At the momment the code does this: 

Topping: Olives
Topping: Olives
Got that already!
Topping: Linus
Topping: 
Topping: Olives, Linus
 
It needs to do this:
Topping: Olives
Topping: Olives
Got that already!
Topping: Linus
Topping: 
Olives, Linus
 

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2854871
Share on other sites

Link to post
Share on other sites

Change

         message = ("Topping: ")

to

         message = ""

Yes!!!!

That's it, fantastic!

Thank you so much for your helop.

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2854899
Share on other sites

Link to post
Share on other sites

Ok then, Ill try solve your other pantry/recipe one a bit later then

Thank you,

I'v changed the code a little:

pantry = input('What is in the pantry? ')
recipe = input('What does the recipe require? ')
recipe2 = recipe.lower()
pantry2 = pantry.lower()
recipe3 = recipe2.split()
pantry3 = pantry2.split()
x = [] 
for i in recipe3:
  if i not in pantry3:
    x.append(i)
            p.append(i)  
print("You need".join(pantry3))  
 
 
It's not finished, but that's what I have at the moment. 

|CPU: Intel 5960X|MOBO:Rampage V Extreme|GPU:EVGA 980Ti SC 2 - Way SLI|RAM:G-Skill 32GB|CASE:900D|PSU:CorsairAX1200i|DISPLAY :Dell U2412M X3|SSD Intel 750 400GB, 2X Samsung 850 Pro|

Peripherals : | MOUSE : Logitech G602 | KEYBOARD: K70 RGB (Cherry MX Brown) | NAS: Synology DS1515+  - WD RED 3TB X 5|ROUTER: AC68U

Sound : | HEADPHONES: Sennheiser HD800 SPEAKERS: B&W CM9 (Front floorstanding) ,  B&W CM Center 2 (Centre) | AV RECEIVER : Denon 3806 | MY X99 BUILD LOG!

 

Link to comment
https://linustechtips.com/topic/210213-what-am-i-missing-python/#findComment-2854916
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×