python_scripting_cms icon indicating copy to clipboard operation
python_scripting_cms copied to clipboard

Introduce `elif` concept

Open khoivan88 opened this issue 4 years ago • 2 comments

Hi, thank you for the tutorial. I just have a suggestion on the use of elif clause instead of just if clause in this block: https://github.com/MolSSI-Education/python_scripting_cms/edit/gh-pages/_episodes/02-file_parsing.md#L256-L268

...
for line in saptlines:
    if 'Electrostatics    ' in line:
        electro_line = line
        important_lines.append(electro_line)
    if 'Exchange       ' in line:
        exchange_line = line
        important_lines.append(exchange_line)
    if 'Induction      ' in line:
        induction_line = line
        important_lines.append(induction_line)
    if 'Dispersion     ' in line:
        dispersion_line = line
        important_lines.append(dispersion_line)
...

khoivan88 avatar Mar 26 '20 18:03 khoivan88

Thank you! I think we may be able to introduce elif (and else in lesson 1 under the heading "making choices"). We use an if statement to get number less than 0, elif could be used to capture numbers equal to zero, and else to get all else.

https://github.com/MolSSI-Education/python_scripting_cms/edit/gh-pages/_episodes/01-introduction.md#L344-384

janash avatar Mar 26 '20 18:03 janash

is this issue still open ?

Nandini1071 avatar Mar 16 '24 15:03 Nandini1071