Q:

Implementing output file extension considering type of workspace in ModelBuilder?

In Modelbuilder, I am trying to implement a condition regarding the type of workspace:

if this is a GDB, the output FC should not have an Extension
(%Scratch%\Nodes_%NameFC%) 
If this is a Folder, the FC Output should
have one.    (%Scratch%\Nodes_%NameFC%.shp)

So far, I built this thinking to use it somehow as a variable to add an extension to the OutputFC if needed. 

In the first case, the returned value is 1, which is "wrong" because the Output Workspace is a fgdb and in the code block, 1 is supposed to be False. 
In the second case, it's not returning anything as the Output Workspace doesn't have any Extension. 
There is a message (when running the first set) ERROR 000539: Error running expression: gdb (...) name 'gdb' is not defined

Does anyone know what is going on here?

A:

Consider testing against the workspace type property.
In your calculate value tool (you only need one for this step), modify your code to look something like this:
import os, arcpy
def workspace_type(wkspace,fc_name):
    wt = arcpy.Describe(wkspace)
    if wt.workspaceType == "FileSystem": #folder
       return os.path.join(wkspace,"{0}.shp".format(fc_name))
    elif wt.workspaceType == "LocalDatabase": #local geodatabase
       return os.path.join(wkspace,fc_name)

