Python Forum
Variable is not defined error when trying to use my custom function code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable is not defined error when trying to use my custom function code
#1
Hi so I recently am transitioning from Snap! to python and im trying to recreate something I did in snap but I am having some problems.

# CONTAINS LETTER BLOCK
def contains_letter(string1,letter):
    for i in len(string1):
        if i==letter:
            print(True)
        else:
            print(False)        

contains_letter(hello,h)
When I put hello and h in it just says undefined variable in the problems section. Also im pretty sure some of that code might not work as well as I was trying to find something that would work with what i want it to do.
buran write Nov-23-2023, 08:48 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Messages In This Thread
Variable is not defined error when trying to use my custom function code - by fnafgamer239 - Nov-23-2023, 08:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Variable not defined even though it is CoderMerv 3 385 Mar-28-2024, 02:13 PM
Last Post: Larz60+
  Variable for the value element in the index function?? Learner1 8 738 Jan-20-2024, 09:20 PM
Last Post: Learner1
  Printing the variable from defined function jws 7 1,437 Sep-03-2023, 03:22 PM
Last Post: deanhystad
  Function parameter not writing to variable Karp 5 1,025 Aug-07-2023, 05:58 PM
Last Post: Karp
  Badly defined python code? Ken76 2 678 May-25-2023, 11:05 PM
Last Post: DigiGod
  Getting NameError for a function that is defined JonWayn 2 1,158 Dec-11-2022, 01:53 PM
Last Post: JonWayn
Question Help with function - encryption - messages - NameError: name 'message' is not defined MrKnd94 4 2,995 Nov-11-2022, 09:03 PM
Last Post: deanhystad
  How to print the output of a defined function bshoushtarian 4 1,363 Sep-08-2022, 01:44 PM
Last Post: deanhystad
  Retrieve variable from function labgoggles 2 1,084 Jul-01-2022, 07:23 PM
Last Post: labgoggles
  User-defined function to reset variables? Mark17 3 1,709 May-25-2022, 07:22 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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