0

So I am trying to self teach myself Python, and so far it is working great. However I have ran into a bump in the road and can't really figure out why this script isn't working... Any ideas?

import os
answer = raw_input('Ready for shutdown, continue?')
if answer == raw_input('Yes'):
os.system("shutdown -s -t 0")
else (return)

Thanks,
Powerade661

Edited by powerade661

2
Contributors
3
Replies
17
Views
1 Year
Discussion Span
Last Post by powerade661
Featured Replies
  • 1

    Change it to import os answer = raw_input('Ready for shutdown, continue?') if answer == 'Yes': os.system("shutdown -s -t 0") First of all, you are trying to ask for two inputs and check whether the two input are the same. What you want to do is getting only one input and … Read More

1

Change it to

import os
answer = raw_input('Ready for shutdown, continue?')
if answer == 'Yes':
     os.system("shutdown -s -t 0")

First of all, you are trying to ask for two inputs and check whether the two input are the same. What you want to do is getting only one input and check if the input is a string "Yes".

Secondly, Indentation in Python has meaning. Anything inside the condition must be one indentation depth than the condition code.

0

I feel so dumb... lol What about the else (return) ? How would I make it so that if anything besides yes was entered, it would do nothing and reply back with a message such as "Ok I will not shutdown just yet." ? Any other resources besides Python's website to help me better grasp this?

Thanks again,
Powerade661

Edited by powerade661

0

Never mind I figured it out. Thanks anyway

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.