Greetings:
I'm brand new to Python and decided to write a syllogism solver for a
class I'm taking. At the start of the program, I define a function that
classifies the type of each statement in the syllogism. Python tells me
that it is expecting an indented block at the s in "some". I can see
what I'm doing wrong. Here's the code:
def class_stmt(q,c) :
"""
This function classifies a statement according to the rules of
categorical syllogisms and returns A, E, I, O to identify the
statement type.
"""
if q.lower() == "all":
if "not" in c:
stmt_type = "E"
else:
stmt_type = "A"
elif q.lower() == "some" # s in some is highlighted
if "not" in c:
stmt_type = "O"
else:
stmt_type = "I"
elif q.lower() == "no":
if "not" in c:
stmt_type = "A"
else:
stmt_type = "E"
else:
if "not" in c:
stmt_type = "E"
else:
stmt_type = "A"
return stmt_type
Any ideas? Thanks in advance.
Keith 7 3556 ka****@gmail.co m wrote:
Greetings:
<snip>
elif q.lower() == "some" # s in some is highlighted
<snip>
Any ideas? Thanks in advance.
Keith
Would the missing colon have something to do with it?
elif q.lower() == "some":
alisonken1 wrote:
ka****@gmail.co m wrote:
Greetings:
<snip>
elif q.lower() == "some" # s in some is highlighted
<snip>
Any ideas? Thanks in advance.
Keith
Would the missing colon have something to do with it?
elif q.lower() == "some":
Thanks for the replies:
I'm sorry, the colon is there in the original, I accidentally blew it
off when I added the comment. The only information I get from IDLE is a
dialog box that says:
Syntax Error
There's an error in your program:
expected an indented block
Keith
Thanks for the replies:
>
I'm sorry, the colon is there in the original, I accidentally blew it
off when I added the comment. The only information I get from IDLE is a
dialog box that says:
Syntax Error
There's an error in your program:
expected an indented block
Keith
To see the full traceback, assuming you're using windows, you need to
run it on the Command prompt.
Dustan wrote:
>
To see the full traceback, assuming you're using windows, you need to
run it on the Command prompt.
Hi Dustan:
Here's the traceback:
C:\docs\Python> SylloSolver.py
File "C:\docs\Python \SylloSolver.py ", line
"""
^
IndentationErro r: expected an indented block
I got rid of the triple quote string at the start of the function, and
that cleared up the problem, though I don't know why.
Thanks
Keith ka****@gmail.co m wrote:
Dustan wrote:
To see the full traceback, assuming you're using windows, you need to
run it on the Command prompt.
Hi Dustan:
Here's the traceback:
C:\docs\Python> SylloSolver.py
File "C:\docs\Python \SylloSolver.py ", line
"""
^
IndentationErro r: expected an indented block
I got rid of the triple quote string at the start of the function, and
that cleared up the problem, though I don't know why.
Thanks
Keith
Ah, yes. The docstring for a function (or at least its first
triple-quote) must be indented to the same degree as its statements.
(If you're using IDLE it should have indented it for you when you hit
return after the def statement.)
HTH,
~Simon
Simon Forman wrote:
I got rid of the triple quote string at the start of the function, and
that cleared up the problem, though I don't know why.
Ah, yes. The docstring for a function (or at least its first
triple-quote) must be indented to the same degree as its statements.
(If you're using IDLE it should have indented it for you when you hit
return after the def statement.)
HTH,
~Simon
Hi Simon:
Thanks. I code in VB / VBA, and use indented structure, but it's not
enforced they way it is in Python - still getting used to that. Also, I
got goofed up editing some of the code in VIM, indenting with tabs, and
then switching to IDLE, with space indentation. Whoops...
Thanks for all the help everyone, my first Python program is now
working!
Keith ka****@gmail.co m wrote:
Simon Forman wrote:
>>I got rid of the triple quote string at the start of the function, and that cleared up the problem, though I don't know why.
Ah, yes. The docstring for a function (or at least its first triple-quote) must be indented to the same degree as its statements. (If you're using IDLE it should have indented it for you when you hit return after the def statement.)
HTH, ~Simon
Hi Simon:
Thanks. I code in VB / VBA, and use indented structure, but it's not
enforced they way it is in Python - still getting used to that. Also, I
got goofed up editing some of the code in VIM, indenting with tabs, and
then switching to IDLE, with space indentation. Whoops...
Thanks for all the help everyone, my first Python program is now
working!
Keith
Tips: if you're coding with VIM, put "set expandtab" in your config
file. That way, each tab will be expanded into the corresponding number
of spaces ... Whatever the language, I find it always a bad idea to mix
spaces and tabs, and I prefer spaces ...
Pierre This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave Benjamin |
last post by:
I ran into an odd little edge case while experimenting with functions that
create classes on the fly (don't ask me why):
>>> def f(x):
... class C(object):
... x = x
... print C.x
...
>>> f(5)
Traceback (most recent call last):
|
by: oooooo0000000 |
last post by:
I have an XML file of varying nesting depth...
<catalouge>
<item id="1">
<name/>
<item id="23">
<name/>
<item id="55">
<name/>
</item>
|
by: Wladimir Borsov |
last post by:
Assume I want to publish a longer article on a web page.
One of the paragraphs I want to display with an indent.
Read: All text lines of this paragraph should be displayed with (let's say 8) blanks
from the "normal" left side.
How do I do that without coding " " ?
Is there something like
<TAB size=8> ..... </TAB> ?
|
by: darius |
last post by:
Hi
I want to do paragraphs with nested indent, like so
para 1 ....
.........
para 2 .......
.....
para 3 ......
.........
|
by: seajays |
last post by:
I've got my page working just as I wanted it - but when I came to
validate the XHTML, using W3c's validator it failed. Essentially as
far as I can see it the problem is this:
1: <div>
2: <a href="somelink.htm">
3: <div>
4: <h2>Title</h2>
5: Some text
6: </div>
| |
by: Christopher P. Winter |
last post by:
I'm seeing some unexpected behavior with Text-indent, as shown on this
page:
http://www.chris-winter.com/Digressions/HP_Kayak/My_Kayak.html
I set up the following style rules for footnotes:
DIV.FootRule { Border-bottom: 1px Solid Gray; Margin-bottom:
2px; Text-align: Left; Width: 20% }
|
by: Martin Eyles |
last post by:
Hi,
I am trying to get two divs to align at the bottom of another div. As
they are nested in this div, I expected them to be positioned at the bottom
of it, using the code below, but they are instead at the bottom of the body.
note - I do want them on top of each other, so the only problem is - where
is the bottom, and how can I make it the same as the bottom of the div.
Thanks, Martin (code below)
<html>
|
by: Sean Givan |
last post by:
Hi. I'm new to Python, and downloaded a Windows copy a little while
ago. I was doing some experiments with nested functions, and ran into
something strange.
This code:
def outer():
val = 10
def inner():
print val
|
by: jdurancomas |
last post by:
Dear all,
I'm trying to declare the operator++ to a nested class. The nested
class is not template but the container it is.
The code used in teh sample program is included bellow:
#include <iostream>
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |