Jump to content

Hello forums,

I need help with Python, been pulling my hair out with this problem. 

 

line = input("What's the magic word?")
while line != "please":
  if please in line:
    print("OK!")
else: line = input("What's the magic word?")
 
 
which produces. 
 
What is the magic word? please
What is the magic word? # repeats "What is the magic word even after "please " is said"
 
It suppose to produce: 
What's the magic word? Do I get some?
What's the magic word? What?
What's the magic word? I dunno.
What's the magic word? Please do I get some?
OK!
 
Which means it suppose to say OK! when please is said. 

|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/203673-python-question-basic/
Share on other sites

Link to post
Share on other sites

If you don't mind not accounting for other ways of typing please (Please, for example):

line = input("What's the magic word?")while "please" not in line:    line = input("What's the magic word?")print("OK!")

CPU - FX 8320 @ 4.8 GHz

| MoBo - Sabertooth 990FX | GPU - XFX Radeon HD 7870 GHz Ed. @ 1.075 GHz | CPU Cooler - H100 | RAM - 16 GB Dual Channel Vengeance @ 1600 MHz (didn't care to push these...) | OS - Windows 8 Pro | Storage - OCZ Vertex 3 (120 GB Boot), Samsung 830 Pro 64 GB, WD Black 1 TB, some random 320 GB from a laptop | PSU - CM Silent Hybrid Pro 850W (MDPC Sleeving) | Case - 800D | Monitors - ASUS V238H/ X Star DP2710LED | Mouse - M90 Keyboard - CM Quickfire Rapid w/ custom key caps

"When life gives you lemons, Don't make lemonade, make life take the lemons back!" - Cave Johnson, CEO

Link to comment
https://linustechtips.com/topic/203673-python-question-basic/#findComment-2765696
Share on other sites

Link to post
Share on other sites

 

If you don't mind not accounting for other ways of typing please (Please, for example):

line = input("What's the magic word?")while "please" not in line:    line = input("What's the magic word?")print("OK!")

Thanks for the help, though it's needs to account for PLEASE, Please and please. 

Thanks again!

|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/203673-python-question-basic/#findComment-2765924
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

×