Python Forum
code not working, NameError: name 's' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
code not working, NameError: name 's' is not defined
#5
just to mention that brackets in your if/elif/else conditions are redundant

if self.cmd[1] in {"S","D","R","W","T"}:
    k = 8
elif self.cmd[1] in {"F","A"}:
    k = 10
elif self.cmd[1] == "C":  
    k = input("Enter the number of bytes? ")   
else: 
    k = 0
if k:
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: code not working..... - by Larz60+ - Oct-05-2020, 06:45 PM
RE: code not working..... - by Yoriz - Oct-05-2020, 06:45 PM
RE: code not working..... - by ridgerunnersjw - Oct-05-2020, 06:47 PM
RE: code not working, NameError: name 's' is not defined - by buran - Oct-05-2020, 07:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I'm getting a NameError: ...not defined. vonArre 2 279 Mar-24-2024, 10:25 PM
Last Post: vonArre
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 583 Nov-23-2023, 02:53 PM
Last Post: rob101
  New to Python - Not sure why this code isn't working - Any help appreciated TheGreatNinx 4 960 Jul-22-2023, 10:21 PM
Last Post: Pedroski55
  code not working when executed from flask app ThomasDC 1 889 Jul-18-2023, 07:16 AM
Last Post: ThomasDC
  Badly defined python code? Ken76 2 613 May-25-2023, 11:05 PM
Last Post: DigiGod
  I am new to python and Could someone please explain how this below code is working? kartheekdas 2 1,014 Dec-19-2022, 05:24 PM
Last Post: kartheekdas
  Getting NameError for a function that is defined JonWayn 2 1,105 Dec-11-2022, 01:53 PM
Last Post: JonWayn
Question Help with function - encryption - messages - NameError: name 'message' is not defined MrKnd94 4 2,886 Nov-11-2022, 09:03 PM
Last Post: deanhystad
Exclamation My code is not working as I expected and I don't know why! Marinho 4 1,077 Oct-13-2022, 08:09 PM
Last Post: deanhystad
  [split] NameError: name 'csvwriter' is not defined. Did you mean: 'writer'? cathy12 4 3,320 Sep-01-2022, 07:41 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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