samedi 1 octobre 2016

Python: If elif

i am trying to create a function that creates an empty coloured picture given the numbers of tiles from createSquareTile(numTiles, prefix)

def createSquareTile(numTiles, prefix):
  current = 1
  if current == 1:
    numTiles = requestNumber("Please input a positive number")
    numTilesI = int(numTiles)

    while (numTilesI < 0):
      showError("Your input number" + str(numTiles)+ "is not valid. Do it       again!")
      numTiles = requestNumber("Please input a positive number")

    if (numTilesI > 0):
    current = current + 1
    color = pickAColor()
    return makeEmptyPicture(numTilesI), numTilesI), color)

  elif current > 1:
    previousChoice = requestString("Same size as pervious tile? (Y/N)")

    while (previous != "N") and (previous != "Y"):
      showError("Your input character" + previousChoice + "is not valid. Do it again!")
      previousChoice = requestString("Same size as previous tile? (Y/N)")

    if (previousChoice == "Y"):
      color = pickAColor()
      return makeEmptyPicture(numTilesI, numTilesI, color)
      current = current + 1


    elif (previousChoice == "N"):
      numTilesN = requestNumber("Please input a positive number")
      numTIlesNI = int(numTilesN)
      colorN = pickAColor()
      return makeEmptyPicture(numTilesNI, numTilesNI, colorN)
      current = current + 1

According to python, there was a spacing error at

elif current > 1:

Could somebody please help me what is wrong with my elif statement? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire