lundi 4 mai 2020

Converting R if (seed) statement into Python [closed]

Working on a project for my Stats class and I've hit a roadblock...

I need to convert this code, given by the professor...

# Set seed if required and determine if seed is not an integer  
#   
       if(!is.null(seed)) {   
              if(is.integer(seed)) set.seed(seed)   
              else stop("Non NULL or Integer Seed") 
       }

...into Python. I thought i got it right, but I'm coming up short with this expression.

 if seed != None :   
              if is_integer(seed) :
              rd.seed(seed)  
                  return
              else :
                  sys.exit("Non NULL or Integer Seed") 

It gives me a "IndentationError: expected an indented block". Can you seed in Python without immediately following it with random.randint()?

Aucun commentaire:

Enregistrer un commentaire