I am working on a bigger project with many steps. I am trying to design a function that takes in my puzzle, sees if something can solve it, then if it cant, simply return the original
def solver(puzzle):
replica=deepcopy(puzzle)
solve(puzzle)
ifcomplete
return puzzle
else:
return replica
I can get it all working but cant make it return the replica. Is there a function to simply to return “original entry” or something similar
This is in regards to Python!
gvm
March 14, 2017, 4:00pm
3
Take care of syntax, indentation etc., preformat the code (Ctrl + Shift + C).
1 Like
I have got it correctly indented it just has shown up on here
Hi @chrussmith , if you format it so that others can see your code as it really is then they will be better able to help.
To format code so it’s visible, either wrap it in single backticks (``` ``) for a small amount of code, or triple backticks on an otherwise blank line before and after for a large amount of code.
1 Like
replica=deepcopy(puzzle)`
solve(puzzle)
if complete:
return puzzle
else:
return replica```
it stilll doesnt seem to indent :(
That is because the three backticks should be on a line by themselves.
1 Like
I’m closing this topic because there is now a second thread for it over here
I made a post yesterday in regards to Python but formatted it horribly.
I am making a code to solve a puzzle. It should take in the puzzle, try to solve it, then if solved, return the solved puzzle (this bit works). However if it cant solve it, then return the original puzzle completely as it was input, which isnt working.
def solve(puzzle):
replica=deepcopy(puzzle)
solve(puzzle)
if complete:
return puzzle
else:
return replica
I …
1 Like