Python Indentation Error when there is no indent error [duplicate]

2024/11/17 1:58:19

Is it me or the interpreter? I see no indentation error in my code but it kept telling me that there is an error! I use auto indentation so it should be ok. When ever there is an indentation error, I backspace then indent again and it seems to fix it because the indentation error is not on that line anymore but on the other line. Can someone please tell me what is wrong

class LogicGate:def __init__(self,n):self.label = nself.output = Nonedef getLabel(self):return self.labeldef getOutput(self):self.output = self.performGateLogic()return self.output

Self answer: the auto indentation of my IDE is indent with tab, and sometimes when I back space I indent it with spaces again. So the problem is mixing spaces and tabs. I recommend setting your IDE to indent with spaces or don't use tabs. See https://www.python.org/dev/peps/

Answer

It would be,

class LogicGate:def __init__(self,n):self.label = nself.output = Nonedef getLabel(self):return self.labeldef getOutput(self):self.output = self.performGateLogic()return self.output
https://en.xdnf.cn/q/118855.html

Related Q&A

How to mark rgb colors on a colorwheel in python? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.Want to improve this question? Add details and clarify the problem by editing this post.Closed 8 months ago.Improv…

Cant get Selenium to loop through two dialogue box options correctly

So basically: the goal is to click on each symbol for each sector on this website, that pops up a table with contact details, I want to copy all of that information and store it in a file. Right now ev…

Is it possible to use a JSON Web Token/JWT in a pip.conf file?

Im trying to make it possible for my application to fetch a package from a private feed in Azure DevOps using pip and a pip.conf file. I dont want to use a PAT for obvious reasons, so Ive created a ser…

sqlite3.Cursor object has no attribute __getitem__ Error in Python Flask

This is my code. I get this error everytime I press login:sqlite3.Cursor object has no attribute __getitem__This is my login tab:@app.route(/, methods=[GET, POST]) def login():error= Noneif request.met…

Merge Sort Implementation Check

I am doubtful of my implementation of the merge sort for two cases specifically:1. If the size of the list is 2, then I have swapped the values if they are not in the ascending order else I have return…

How to create a def in python that pick a specific value and then make a new dict like this

myDict ={"key1" : "val1","key2" : "val2","key3" : "val3","key4" : "x","key5" : "x"}I need a def in py…

Inputs required in python on csv files

I have a problem and need to solve it using Pandas/Python. Not sure how to achieve it and would be great if someone help here to build the logic. I have to generate the output file as below: df = pd.Da…

ServiceBusError : Handler failed: tuple object has no attribute get_token

Im getting the below error when i run my code. This code is to requeue the Deadletter messages. Error: Exception has occurred: ServiceBusError Handler failed: tuple object has no attribute get_token. A…

sqlite3.OperationalError: near WHERE: syntax error

I want to update a series of columns Country1, Country2... Country 9 based on a comma delimited string of country names in column Country. Ive programmed a single statement to accomplish this task. cur…

If statement not working correctly in Python 3

This is the start of an RPG I am going to make, and It runs smoothly until I try to change the gender by saying yes or any other of the answers that activate the if statement. Is there something I am f…