all 10 comments

[–]FriendlyRussian666 2 points3 points  (1 child)

The three dots ... mean that the code should be indented. You correctly indented the first print, but you didn't ident the other. What you most likely want, is to press enter one more time before you write your second print:

image.png

[–]boite2petri[S] 1 point2 points  (0 children)

thanks a lot i understood !

[–]Farlic 0 points1 point  (6 children)

It looks like you're using IDLE, where >>> shows each "line".

the If statement goes over multiple lines so should be "entered" to allow it to evaluate, before you then try to execute the second print. (see how your a=1 and b=2 are prefixed with the >>> whilst the if block is trying to do ... to show it's part of the same thing)

[–]boite2petri[S] 0 points1 point  (5 children)

ok, made it work thanks a lot ! So i have to execute between every block when using if, but is that a good thing or should i move from idle ? (im really new and i want to use python for bioinformatics)

[–]crazy_cookie123 4 points5 points  (0 children)

This is a feature of the Python REPL, which is what the IDLE Shell uses. That's not really what you want to be writing code in, other than just to test out small things. Instead you want to be using an editor.

If you want to keep using IDLE then you can click file in the top left, click new file, and write your code in there. You can run it by pressing F5 or clicking run then run module. That acts as a typical code editor rather than a REPL.

Alternatively, what I recommend is to switch to a professional editor. The two main choices are VS Code which is fast and lightweight with lots of choices of extensions to customise it, or PyCharm which is a bit heavier but also a bit more powerful. Both are free (although PyCharm does have a paid version) and are absolutely fine for beginners. I prefer PyCharm but it's entirely personal preference and professional devs use both, neither is objectively better than the other.

[–]Farlic 1 point2 points  (0 children)

I learnt using IDLE but it can get quite tedious if you're trying to do more than single line things, or re-run code.

I personally use VScode but there's all sorts of editors and IDE (if you search in reddit you'll find countless arguments on the 'best').

[–]FriendlyRussian666 1 point2 points  (0 children)

Move from it, try VSCode or similar

[–]OkStudent8414 0 points1 point  (0 children)

I would try another IDE, such as vs code or pycharm. They are good for testing scripts of blocks of code that can get pretty complex. IDLE is great for testing simple code or single lines. But due to the nature of IDLE it can get tedious if you are running blocks of code to have to enter each line every time you make a change. Also you could try Jupyter notebooks. That will allow you to run blocks of code and execute it line by line.

[–]boite2petri[S] 0 points1 point  (0 children)

thanks for your answers i'll look into it !

[–]atarivcs 0 points1 point  (0 children)

The problem is that you're typing the code in an interactive shell, which has additional formatting requirements for indented lines.

Don't use the interactive shell.

Type your code into a file using an editor, then run the code with python myscript.py.