#🔒 is there a command to make it so i can return but not return if that makes sense?

26 messages · Page 1 of 1 (latest)

pallid thistle
#
a = 0
def randommmmmmmm(a):
    return 0
    a += 1
    return a
randommmmmmmm(a)
print(a)

for example id want a to print 1 here instead of 0

loud schoonerBOT
#

@pallid thistle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

pearl dove
#

wtf

#

explain what do u wanna achive

pallid thistle
#

i want to have a "return" but i dont want the function to end

#

yeah i kinda worded it a little odd haha

pearl dove
#

if u use return the function ends

#

try print then?

pallid thistle
#

print is just there as an example sorry for the confusion

#

i was just trying to send something a little less annoying to read

#

i can send my actual code if it makes it easier to help me

#
def MazeMovebackward(moves):
    passagecheck = 0
    tootired = 0
    if move(moves[0]):
        move(moves[4])
        passagecheck += 1
        tootired = 1
        return moves[1],get_pos_x(),get_pos_y()
    if move(moves[2]):
        move(moves[6])
        passagecheck += 1
        tootired = 2
        return moves[3],get_pos_x(),get_pos_y()
    if move(moves[4]):
        move(moves[0])
        passagecheck += 1
        tootired = 3
        return moves[5],get_pos_x(),get_pos_y()
    if move(moves[6]):
        move(moves[2])
        passagecheck += 1
        tootired = 4
        return moves[5],get_pos_x(),get_pos_y()
    if tootired == 1:
        move(moves[0])
    elif tootired == 2:
        move(moves[2])
    elif tootired == 3:
        move(moves[4])
    elif tootired == 4:
        move(moves[6])
    elif tootired == 0:
        while True:
            print('error')
    if passagecheck >= 2:
        while True:
            print('passagecheck True')
        return 4,0
reef jay
#

understand the squence of opration. every thing will run from top to bottom. once a funcation is called then go from top to bottom

pearl dove
#
def MazeMovebackward(moves):
    passagecheck = 0
    tootired = 0
    direction_pairs = [(0, 4), (2, 6), (4, 0), (6, 2)]
    
    for i, (move1, move2) in enumerate(direction_pairs):
        if move(moves[move1]):
            move(moves[move2])
            passagecheck += 1
            tootired = i + 1
            return moves[move1 + 1], get_pos_x(), get_pos_y()
    
    if tootired:
        move(moves[direction_pairs[tootired - 1][0]])
    else:
        while True:
            print('error')
    
    if passagecheck >= 2:
        while True:
            print('passagecheck True')
        return 4, 0
reef jay
#
a = 0
def randommmmmmmm(a):
    add a condition here 
    # if a == 0: 
    return 0
    a += 1
    return a
randommmmmmmm(a)
print(a)
#

somthing like this

pallid thistle
pearl dove
#

if ur trying to do smth

#

ask chatgpt to opetimize it

#

and then learn how and why it does it

pearl dove
pallid thistle
loud schoonerBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

🔒 is there a command to make it so i can return but not return if that makes sense?