I am learning Python (named after the Monty Python shows, not the reptile) and one of the most basic statements is the "elif" statement. It is short of "Else if..." and I think Scratch needs it. After all, what kind of project asks a question and if it gets a "Yes" does one thing, and if it gets "No" does another, and if it gets "qwertyuiop" does "No"?
Offline
Somewhat.. you probably meant another 'If Else' block placed inside the 'Else' of a first 'If Else' Block, just to clear up any confusion on the part of maxskywalker.
Offline
As Ace-of-Spades mentioned, you can in fact place "if else" inside an "if else."
A lot of scripting room could be saved with this block, however - something of a button that creates another "else if" statement without indenting the new block would be really handy, and teach some more accurate programming skills. I certainly agree with this idea
Offline
In Python, sometimes you need more than just one Elif though, so the If Else in the Else space would be the best way to go at it for now.
Offline
I think it would be better to simply place two blocks together than create a whole new block.
Offline
coolstuff wrote:
As Ace-of-Spades mentioned, you can in fact place "if else" inside an "if else."
A lot of scripting room could be saved with this block, however - something of a button that creates another "else if" statement without indenting the new block would be really handy, and teach some more accurate programming skills. I certainly agree with this idea![]()
I don't think you understand. This is how elif is used in python:
x = raw_input("Who's the best Scratcher ever?")
while x != "Jimmy-Jermaine":
if"Jimmy-Jermaine"in x:
print "I agree!"
elif"archmage"in x:
print "Did you mean Jimmy-Jermaine?"
elif"RHY3756547"in x:
print "Did you mean Jimmy-Jermaine?"
elif"m44"in x:
print "Did you mean Jimmy-Jermaine?"
else:
print "That's not right, the proper answer is Jimmy-Jermaine."
They won't make 10 different blocks with varying lengths of Elif dents in them if it can be done with the simple combination of 2 or more blocks.
Offline
Jimmy-Jermaine wrote:
I don't think you understand. This is how elif is used in python:
...
They won't make 10 different blocks with varying lengths of Elif dents in them if it can be done with the simple combination of 2 or more blocks.
I did, in fact, understand - I was suggesting a button that would add another if statement to the block, much like the arrow that is used in BYOB.
Offline
BYOB? Never heard of it. Do you mean BYOND?
Offline
I've never heard of them, and I don't trust any of these 'Scratch Mods', they could be viruses in disguise.
Offline
Jimmy-Jermaine wrote:
I've never heard of them, and I don't trust any of these 'Scratch Mods', they could be viruses in disguise.
It doesn't matter, I was simply using the modification as an example. Besides, this modification is one of, if not the, most well-respected modification.
Offline
coolstuff wrote:
As Ace-of-Spades mentioned, you can in fact place "if else" inside an "if else."
A lot of scripting room could be saved with this block, however - something of a button that creates another "else if" statement without indenting the new block would be really handy, and teach some more accurate programming skills. I certainly agree with this idea![]()
Agreed. If you had to stack a lot of "If, else" blocks inside each other, looking at all those C blocks could get confusing really fast. This solution would work really well, in a similar fashion to BYOB's "The list: [] <- ->" blocks. (The arrows add/remove a space for an argument in the block.)
Offline
You can just put an if block inside the else if.
I don't think it really needs to be added, it would take up more space and if you cant be bothered to place 1 more block then sorry but I think you are just being lazy.
Offline
Jimmy-Jermaine wrote:
I've never heard of them, and I don't trust any of these 'Scratch Mods', they could be viruses in disguise.
that's a fair guess. actually, BYOB is probably the safest, as jens was once a part of the scratch team.
Offline
I work with python too, and I actually do agree that Scratch should have it
I actually had trouble with my "Vanishing Bridge" project relating to this. When it asks for difficulty, they could type stuff and it will continue with the game at difficulty 0
.
Last edited by terminator68 (2010-07-24 12:47:46)

Offline
colorfusion wrote:
You can just put an if block inside the else if.
I don't think it really needs to be added, it would take up more space and if you cant be bothered to place 1 more block then sorry but I think you are just being lazy.
I think you misunderstand - it's not the time we're worried about, it's the space. If you had a little arrow to add another "if" statement to add another item, it would take up a LOT less space - the endless line of "if... else" statements in most projects is a little unsettling, to be honest
Offline
In Scratch you can do this:
[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...
Offline
ThePCKid wrote:
In Scratch you can do this:
[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...
Well yeah, but once you start getting a lot of those stacked inside each other, it gets really oversized, cluttered, and confusing.
An Else-if alternative would be much better.
Last edited by Harakou (2010-07-27 00:10:06)
Offline
Harakou wrote:
ThePCKid wrote:
In Scratch you can do this:
[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...Well yeah, but once you start getting a lot of those stacked inside each other, it gets really oversized, cluttered, and confusing.
An Else-if alternative would be much better.
That would be confusing
Offline
ThePCKid wrote:
Harakou wrote:
ThePCKid wrote:
In Scratch you can do this:
[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...Well yeah, but once you start getting a lot of those stacked inside each other, it gets really oversized, cluttered, and confusing.
An Else-if alternative would be much better.
That would be confusing
How so? If you can understand If-else, than Else-if doesn't seem that hard to comprehend.
Offline
ThePCKid wrote:
Harakou wrote:
ThePCKid wrote:
In Scratch you can do this:
[if <blah>]
|
|[else]
||[if <blah>]
|||
|||[else]
||||...Well yeah, but once you start getting a lot of those stacked inside each other, it gets really oversized, cluttered, and confusing.
An Else-if alternative would be much better.
That would be confusing
I'm with Harakou on this one - it's actually just as easy to understand as if-else. It's really cluttered and hard to use right now.
Offline