Python Forum
input defines variable but it's not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
input defines variable but it's not defined
#3
(Jun-04-2017, 11:40 AM)tozqo Wrote:    elif(var != 'add' and var != 'subtract' and var != 'multiply' and var != 'divide'):
This should just be else. If control has reached the bottom of that if condition and has already compared to those strings then its not any of those strings and there is no need to redo the condition.

Quote:To get it out of that function, you need to use a return statement. To get it into another function, you use parameters to the function call
this is one reason why one would use a class in some cases as they no longer have to pass a variable back and forth....but you should first get a handle on how to do that before tackling classes.

And thank you for reading what to include in a post before your first post. It is pleasant to read posts when it is short and sweet, but yet not vague and gives enough information to allow a response instead of digging for more info. As well as a short description of attempts to fix. I wish more beginner posts were of this nature.
Recommended Tutorials:
Reply


Messages In This Thread
RE: input defines variable but it's not defined - by metulburr - Jun-04-2017, 06:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Variable not defined even though it is CoderMerv 3 391 Mar-28-2024, 02:13 PM
Last Post: Larz60+
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 656 Nov-23-2023, 02:53 PM
Last Post: rob101
  Printing the variable from defined function jws 7 1,467 Sep-03-2023, 03:22 PM
Last Post: deanhystad
  input variable choice MCL169 7 1,251 Feb-19-2023, 09:00 PM
Last Post: MCL169
  [variable] is not defined error arises despite variable being defined TheTypicalDoge 4 2,239 Apr-05-2022, 04:55 AM
Last Post: deanhystad
  How to include input as part of variable name Mark17 4 2,577 Oct-01-2021, 06:45 PM
Last Post: Mark17
  Function will not return variable that I think is defined Oldman45 6 3,621 Aug-18-2020, 08:50 PM
Last Post: deanhystad
  trying to input a variable using random.choice python63 9 3,708 Aug-13-2020, 05:37 PM
Last Post: python63
  How to assign a module to a variable even if it's not defined? mandaxyz 5 3,354 Aug-12-2020, 10:34 PM
Last Post: snippsat
  Variable not defined Heyjoe 4 2,619 Jul-10-2020, 11:27 PM
Last Post: Heyjoe

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020