Don't understand this conversion program's elif syntax error
I'm running this in python 3 and it keeps telling me there's a traceback. elif is a syntax error. I've tried to troubleshoot but I just can't fix it. When helping me could you please fix the code directly since i'm not good with implementing foreign code. It's meant to return back the please select your conversion if the following options are not selected but obviously not working. Thank You!
from turtle import Screen, Turtle
print("Please select your conversion:")
invalid_input = True
def Converter() :
conversion = input ("metric to metric type mm, metric to imperial type mi, units of water type w, for physics equations type p, for math equations type m and for quick facts type q:")
print("Please select your conversion:")
if conversion == "mm":
#selection = "metric to metric conversions!"
elif conversion == "mi":
selection = "metric to imperial conversions!"
invalid_input = False
elif conversion == "w":
selection = "water conversions!"
invalid_input = False
elif conversion == "p":
selection = "physics equations!"
invalid_input = False
elif conversion == "m":
selection = "maths equations!"
invalid_input = False
elif conversion == "q":
selection = "quick facts!"
invalid_input = False
else:
print("n")
print("Invalid! Please try again.n n n")
while invalid_input :
print("n")
print("You have selected", selection + "!")
invalid_input = True
def start() :
decision = input ("Is this correct? If correct type y, if incorrect type n.")
if decision == "y":
#stuff
invalid_input = False
while invalid_input : # this will loop until invalid_input is set to be True
start()
python python-3.x python-3.6
add a comment |
I'm running this in python 3 and it keeps telling me there's a traceback. elif is a syntax error. I've tried to troubleshoot but I just can't fix it. When helping me could you please fix the code directly since i'm not good with implementing foreign code. It's meant to return back the please select your conversion if the following options are not selected but obviously not working. Thank You!
from turtle import Screen, Turtle
print("Please select your conversion:")
invalid_input = True
def Converter() :
conversion = input ("metric to metric type mm, metric to imperial type mi, units of water type w, for physics equations type p, for math equations type m and for quick facts type q:")
print("Please select your conversion:")
if conversion == "mm":
#selection = "metric to metric conversions!"
elif conversion == "mi":
selection = "metric to imperial conversions!"
invalid_input = False
elif conversion == "w":
selection = "water conversions!"
invalid_input = False
elif conversion == "p":
selection = "physics equations!"
invalid_input = False
elif conversion == "m":
selection = "maths equations!"
invalid_input = False
elif conversion == "q":
selection = "quick facts!"
invalid_input = False
else:
print("n")
print("Invalid! Please try again.n n n")
while invalid_input :
print("n")
print("You have selected", selection + "!")
invalid_input = True
def start() :
decision = input ("Is this correct? If correct type y, if incorrect type n.")
if decision == "y":
#stuff
invalid_input = False
while invalid_input : # this will loop until invalid_input is set to be True
start()
python python-3.x python-3.6
Can you please add in the stacktrace? Or perhaps even a link to something like a repl or fiddle with your code?
– Dakota Maker
Nov 20 at 21:46
You have commented the only statementselection ...
below theif
statement - it needs at leastpass
below it
– barny
Nov 20 at 21:48
Once you get the syntax issue figured-out, I suggest you read Asking the user for input until they give a valid response.
– martineau
Nov 20 at 21:57
@DakotaMaker repl.it/@15nalaas/Science-Converter-11?language=python3
– Nour Alaas
Nov 20 at 21:59
add a comment |
I'm running this in python 3 and it keeps telling me there's a traceback. elif is a syntax error. I've tried to troubleshoot but I just can't fix it. When helping me could you please fix the code directly since i'm not good with implementing foreign code. It's meant to return back the please select your conversion if the following options are not selected but obviously not working. Thank You!
from turtle import Screen, Turtle
print("Please select your conversion:")
invalid_input = True
def Converter() :
conversion = input ("metric to metric type mm, metric to imperial type mi, units of water type w, for physics equations type p, for math equations type m and for quick facts type q:")
print("Please select your conversion:")
if conversion == "mm":
#selection = "metric to metric conversions!"
elif conversion == "mi":
selection = "metric to imperial conversions!"
invalid_input = False
elif conversion == "w":
selection = "water conversions!"
invalid_input = False
elif conversion == "p":
selection = "physics equations!"
invalid_input = False
elif conversion == "m":
selection = "maths equations!"
invalid_input = False
elif conversion == "q":
selection = "quick facts!"
invalid_input = False
else:
print("n")
print("Invalid! Please try again.n n n")
while invalid_input :
print("n")
print("You have selected", selection + "!")
invalid_input = True
def start() :
decision = input ("Is this correct? If correct type y, if incorrect type n.")
if decision == "y":
#stuff
invalid_input = False
while invalid_input : # this will loop until invalid_input is set to be True
start()
python python-3.x python-3.6
I'm running this in python 3 and it keeps telling me there's a traceback. elif is a syntax error. I've tried to troubleshoot but I just can't fix it. When helping me could you please fix the code directly since i'm not good with implementing foreign code. It's meant to return back the please select your conversion if the following options are not selected but obviously not working. Thank You!
from turtle import Screen, Turtle
print("Please select your conversion:")
invalid_input = True
def Converter() :
conversion = input ("metric to metric type mm, metric to imperial type mi, units of water type w, for physics equations type p, for math equations type m and for quick facts type q:")
print("Please select your conversion:")
if conversion == "mm":
#selection = "metric to metric conversions!"
elif conversion == "mi":
selection = "metric to imperial conversions!"
invalid_input = False
elif conversion == "w":
selection = "water conversions!"
invalid_input = False
elif conversion == "p":
selection = "physics equations!"
invalid_input = False
elif conversion == "m":
selection = "maths equations!"
invalid_input = False
elif conversion == "q":
selection = "quick facts!"
invalid_input = False
else:
print("n")
print("Invalid! Please try again.n n n")
while invalid_input :
print("n")
print("You have selected", selection + "!")
invalid_input = True
def start() :
decision = input ("Is this correct? If correct type y, if incorrect type n.")
if decision == "y":
#stuff
invalid_input = False
while invalid_input : # this will loop until invalid_input is set to be True
start()
python python-3.x python-3.6
python python-3.x python-3.6
edited Nov 20 at 21:56
martineau
65.6k989177
65.6k989177
asked Nov 20 at 21:44
Nour Alaas
14
14
Can you please add in the stacktrace? Or perhaps even a link to something like a repl or fiddle with your code?
– Dakota Maker
Nov 20 at 21:46
You have commented the only statementselection ...
below theif
statement - it needs at leastpass
below it
– barny
Nov 20 at 21:48
Once you get the syntax issue figured-out, I suggest you read Asking the user for input until they give a valid response.
– martineau
Nov 20 at 21:57
@DakotaMaker repl.it/@15nalaas/Science-Converter-11?language=python3
– Nour Alaas
Nov 20 at 21:59
add a comment |
Can you please add in the stacktrace? Or perhaps even a link to something like a repl or fiddle with your code?
– Dakota Maker
Nov 20 at 21:46
You have commented the only statementselection ...
below theif
statement - it needs at leastpass
below it
– barny
Nov 20 at 21:48
Once you get the syntax issue figured-out, I suggest you read Asking the user for input until they give a valid response.
– martineau
Nov 20 at 21:57
@DakotaMaker repl.it/@15nalaas/Science-Converter-11?language=python3
– Nour Alaas
Nov 20 at 21:59
Can you please add in the stacktrace? Or perhaps even a link to something like a repl or fiddle with your code?
– Dakota Maker
Nov 20 at 21:46
Can you please add in the stacktrace? Or perhaps even a link to something like a repl or fiddle with your code?
– Dakota Maker
Nov 20 at 21:46
You have commented the only statement
selection ...
below the if
statement - it needs at least pass
below it– barny
Nov 20 at 21:48
You have commented the only statement
selection ...
below the if
statement - it needs at least pass
below it– barny
Nov 20 at 21:48
Once you get the syntax issue figured-out, I suggest you read Asking the user for input until they give a valid response.
– martineau
Nov 20 at 21:57
Once you get the syntax issue figured-out, I suggest you read Asking the user for input until they give a valid response.
– martineau
Nov 20 at 21:57
@DakotaMaker repl.it/@15nalaas/Science-Converter-11?language=python3
– Nour Alaas
Nov 20 at 21:59
@DakotaMaker repl.it/@15nalaas/Science-Converter-11?language=python3
– Nour Alaas
Nov 20 at 21:59
add a comment |
1 Answer
1
active
oldest
votes
Python expects some code (at least one line) inside your conditionals. If you don't have anything to put right now, you can put pass
:
if conversion == "mm":
#selection = "metric to metric conversions!"
pass
elif conversion == "mi":
#selection = "metric to imperial conversions!"
pass
elif conversion == "w":
#selection = "water conversions!"
pass
elif conversion == "p":
#selection = "physics equations!"
pass
elif conversion == "m":
#selection = "maths equations!"
pass
elif conversion == "q":
#selection = "quick facts!"
pass
could you please have a look at the code, i have a more updated version now. thx help is much appreciated.
– Nour Alaas
Nov 20 at 21:53
Your firstif
statement is still empy. Addpass
inside it.
– Aurora Wang
Nov 20 at 21:58
How can I add leave the loop and onto the next one if mm, mi, w, p, m and q are selected, my code now just asks the question again.
– Nour Alaas
Nov 21 at 21:23
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402044%2fdont-understand-this-conversion-programs-elif-syntax-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Python expects some code (at least one line) inside your conditionals. If you don't have anything to put right now, you can put pass
:
if conversion == "mm":
#selection = "metric to metric conversions!"
pass
elif conversion == "mi":
#selection = "metric to imperial conversions!"
pass
elif conversion == "w":
#selection = "water conversions!"
pass
elif conversion == "p":
#selection = "physics equations!"
pass
elif conversion == "m":
#selection = "maths equations!"
pass
elif conversion == "q":
#selection = "quick facts!"
pass
could you please have a look at the code, i have a more updated version now. thx help is much appreciated.
– Nour Alaas
Nov 20 at 21:53
Your firstif
statement is still empy. Addpass
inside it.
– Aurora Wang
Nov 20 at 21:58
How can I add leave the loop and onto the next one if mm, mi, w, p, m and q are selected, my code now just asks the question again.
– Nour Alaas
Nov 21 at 21:23
add a comment |
Python expects some code (at least one line) inside your conditionals. If you don't have anything to put right now, you can put pass
:
if conversion == "mm":
#selection = "metric to metric conversions!"
pass
elif conversion == "mi":
#selection = "metric to imperial conversions!"
pass
elif conversion == "w":
#selection = "water conversions!"
pass
elif conversion == "p":
#selection = "physics equations!"
pass
elif conversion == "m":
#selection = "maths equations!"
pass
elif conversion == "q":
#selection = "quick facts!"
pass
could you please have a look at the code, i have a more updated version now. thx help is much appreciated.
– Nour Alaas
Nov 20 at 21:53
Your firstif
statement is still empy. Addpass
inside it.
– Aurora Wang
Nov 20 at 21:58
How can I add leave the loop and onto the next one if mm, mi, w, p, m and q are selected, my code now just asks the question again.
– Nour Alaas
Nov 21 at 21:23
add a comment |
Python expects some code (at least one line) inside your conditionals. If you don't have anything to put right now, you can put pass
:
if conversion == "mm":
#selection = "metric to metric conversions!"
pass
elif conversion == "mi":
#selection = "metric to imperial conversions!"
pass
elif conversion == "w":
#selection = "water conversions!"
pass
elif conversion == "p":
#selection = "physics equations!"
pass
elif conversion == "m":
#selection = "maths equations!"
pass
elif conversion == "q":
#selection = "quick facts!"
pass
Python expects some code (at least one line) inside your conditionals. If you don't have anything to put right now, you can put pass
:
if conversion == "mm":
#selection = "metric to metric conversions!"
pass
elif conversion == "mi":
#selection = "metric to imperial conversions!"
pass
elif conversion == "w":
#selection = "water conversions!"
pass
elif conversion == "p":
#selection = "physics equations!"
pass
elif conversion == "m":
#selection = "maths equations!"
pass
elif conversion == "q":
#selection = "quick facts!"
pass
answered Nov 20 at 21:49
Aurora Wang
682216
682216
could you please have a look at the code, i have a more updated version now. thx help is much appreciated.
– Nour Alaas
Nov 20 at 21:53
Your firstif
statement is still empy. Addpass
inside it.
– Aurora Wang
Nov 20 at 21:58
How can I add leave the loop and onto the next one if mm, mi, w, p, m and q are selected, my code now just asks the question again.
– Nour Alaas
Nov 21 at 21:23
add a comment |
could you please have a look at the code, i have a more updated version now. thx help is much appreciated.
– Nour Alaas
Nov 20 at 21:53
Your firstif
statement is still empy. Addpass
inside it.
– Aurora Wang
Nov 20 at 21:58
How can I add leave the loop and onto the next one if mm, mi, w, p, m and q are selected, my code now just asks the question again.
– Nour Alaas
Nov 21 at 21:23
could you please have a look at the code, i have a more updated version now. thx help is much appreciated.
– Nour Alaas
Nov 20 at 21:53
could you please have a look at the code, i have a more updated version now. thx help is much appreciated.
– Nour Alaas
Nov 20 at 21:53
Your first
if
statement is still empy. Add pass
inside it.– Aurora Wang
Nov 20 at 21:58
Your first
if
statement is still empy. Add pass
inside it.– Aurora Wang
Nov 20 at 21:58
How can I add leave the loop and onto the next one if mm, mi, w, p, m and q are selected, my code now just asks the question again.
– Nour Alaas
Nov 21 at 21:23
How can I add leave the loop and onto the next one if mm, mi, w, p, m and q are selected, my code now just asks the question again.
– Nour Alaas
Nov 21 at 21:23
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402044%2fdont-understand-this-conversion-programs-elif-syntax-error%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you please add in the stacktrace? Or perhaps even a link to something like a repl or fiddle with your code?
– Dakota Maker
Nov 20 at 21:46
You have commented the only statement
selection ...
below theif
statement - it needs at leastpass
below it– barny
Nov 20 at 21:48
Once you get the syntax issue figured-out, I suggest you read Asking the user for input until they give a valid response.
– martineau
Nov 20 at 21:57
@DakotaMaker repl.it/@15nalaas/Science-Converter-11?language=python3
– Nour Alaas
Nov 20 at 21:59