Sep-18-2018, 01:29 AM
If they did not teach to name variables in English...
Variable names are part of function documentation, helping your reader to understand the code. Portuguese - you are discouraging your potential helpers from the international community.
Also, your code is too crowded, make it still less readable - see PEP-8 for guidance. And don't show the full code - show just places that don't work (again, helps your potential helpers to concentrate on your problem - and not on long strings most won't be able to read)
Still:
Couple of generic pointers:
Variable names are part of function documentation, helping your reader to understand the code. Portuguese - you are discouraging your potential helpers from the international community.
Also, your code is too crowded, make it still less readable - see PEP-8 for guidance. And don't show the full code - show just places that don't work (again, helps your potential helpers to concentrate on your problem - and not on long strings most won't be able to read)
Still:
- Use this site to practice RE and RT(F)M for guidance. Try to figure out the common pattern - that is the purpose of RE, not endless
if/elif/else
chain
re.match
searches from the beginning of the string;^
symbol is redundant.
{1}
is a redundant and stupid quantity modifier; it actually says "this string (sub-RE) will appear once"; if some string(sub-RE) shows within RE without quantity modifier - it means that you expect it to show once
E.g,TCAGR{1}
means that you expect stringTCAG
, followed by oneR
(actually, string comparison will do). You crowd your RE with meaningless modifiers, making them still harder to read
Couple of generic pointers:
pedido[3]==1 or pedido[3]==2 or pedido[3]==4 or pedido[3]==5
may be rewritten (take your pick)
pedido[3] in [1, 2, 3, 4, 5] 1 <= pedido[3] <= 5 pedido[3] in range(1, 6)
- Most of your choice function are candidates for dict
int(pedido[3]) == 1
orpedido[3] == '1'
?
- Indents - well, you were already told
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.