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
#6
Thanks for the globals advice. I added the calls, found out that it was doing the input() function twice(once for the global and once for the compute() call) and fixed that and found out that the variables don't use the same name across functions, but they do use the same input order.

changing from "num1, num2, var = inputs()"
to "var, num1, num2 = inputs()" always returns "No comprende" because var is first variable pulled by the compute() function, and is a number. Also, fiddling around with if's got different outputs. First, I had to change my statements from add(), etc. to add(num1, num2), etc. Leaving the () empty returned nothing, and the order of what I had in () changed the output. ex: if subtract() was changed to subtract(num1, num2) it returned num1 - num2; but if I changed to subtract(num2, num1) it returned num2 - num1, because the input order for the subtract() function was reversed.

I haven't read through all of the function tutorial in ichabod801's link, so I don't know if that is mentioned there yet.

I think I've gotten everything for this sorted out that I needed. Thanks very much for the help.
Reply


Messages In This Thread
RE: input defines variable but it's not defined - by tozqo - Jun-05-2017, 02:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Variable not defined even though it is CoderMerv 3 401 Mar-28-2024, 02:13 PM
Last Post: Larz60+
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 668 Nov-23-2023, 02:53 PM
Last Post: rob101
  Printing the variable from defined function jws 7 1,487 Sep-03-2023, 03:22 PM
Last Post: deanhystad
  input variable choice MCL169 7 1,259 Feb-19-2023, 09:00 PM
Last Post: MCL169
  [variable] is not defined error arises despite variable being defined TheTypicalDoge 4 2,250 Apr-05-2022, 04:55 AM
Last Post: deanhystad
  How to include input as part of variable name Mark17 4 2,587 Oct-01-2021, 06:45 PM
Last Post: Mark17
  Function will not return variable that I think is defined Oldman45 6 3,637 Aug-18-2020, 08:50 PM
Last Post: deanhystad
  trying to input a variable using random.choice python63 9 3,750 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,370 Aug-12-2020, 10:34 PM
Last Post: snippsat
  Variable not defined Heyjoe 4 2,627 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