-2

I'm trying to create a separate function which takes an integer input. I want to then insert that function I created into the main function by only calling it by the name I gave it. I must be misunderstanding something about the def() and how to call the defined function? I added a simplified example of what I'm trying to do below

#This would be the function I make to use later in main program
def functionforlater(value):
    if(value == 2):
       print("oranges")
    else:
       print("try again")


#This would be the main program
for(int x=0;x>3;x++):
    functionforlater(x)

# I've now come to the conclusion that the main program is the fault since there is no 
# such thing as for(int x=0;x>3;x++) in python they use "for x in range()" or xrange

#Solution for main program would be
for x in xrange(4):
    functionforlater(x)
  • One thing you can do now is learn Python syntax by taking some online course. It's pretty pointless asking here, as it's unlikely it would be answered. – Austin Jan 08 '19 at 16:53
  • Sorry, we can't accept images of code or errors. Post those as *text*, so that we can try to reproduce the problem without having to re-type everything, and your question can be properly indexed, etc. – Martijn Pieters Jan 08 '19 at 16:55
  • @MartijnPieters I've added the code thanks for letting me know... problem solved – Ægir Máni Hauksson Jan 08 '19 at 20:32

1 Answers1

-1

Try this way:

def findASCI(value):
    if value == 2:
        print("oranges")
    else :
        print("try again")
XiosGD
  • 77
  • 1
  • 8