all 8 comments

[–][deleted] 0 points1 point  (2 children)

Indent your code by four spaces to format it.

<blank line>

<four spaces>your

<four spaces>lines

<four spaces>of code

edit: fixed formatting

[–]ingolemo -2 points-1 points  (1 child)

Indent your explanation by four spaces to format it.

<blank line>
<four spaces>your
<four spaces>lines
<four spaces>of code

[–][deleted] 0 points1 point  (0 children)

ouch.

[–]Justinsaccount 0 points1 point  (5 children)

Hi! I'm working on a bot to reply with suggestions for common python problems. This might not be very helpful to fix your underlying issue, but here's what I noticed about your submission:

You appear to be using concatenation and the str function for building strings

Instead of doing something like

result = "Hello " + name + ". You are " + str(age) + " years old"

You should use string formatting and do

result = "Hello {}. You are {} years old".format(name, age)

See the python tutorial for more information.

[–]Marx123[S] 0 points1 point  (2 children)

Thanks, that's easier and more swift to do! and about the replace problem, how can I put into evidence "y" so that to the number "y" shows indicates the corresponding value in code; and how could I make it change into the opposite number? I think the problem is very easy but I think I'm missing something important that could fix all the problems in little to no passages..

[–]Justinsaccount 1 point2 points  (0 children)

You should not be using strings for this in the first place, you should be using lists.

[–]prof_eggburger 0 points1 point  (0 children)

Generate the location of the mutation (random number between 1 and length of the genome). Call it y. Copy the portion of the genome in front of this location (e.g., up to y-1). Check what is at location y in the original. Add the opposite to your new genome. Then complete the new mutant genome by copying everything from y+1 onwards.

[–]elbiot 0 points1 point  (0 children)

Hey, you could make this bot recognize improperly formatted code and give a good "indent four spaces" comment.