![](/img/trans.png)
[英]How to reduce multiple if not condition in single line or less code in python?
[英]How to reduce steps / line of code for this puzzle in python?
如果不能使用分號,可以將Dev.step(i+4)
和Dev.step(i+2)
組合成一行,並更改Dev.turnleft()
和Dev.step()
的順序內部循環,因此您得到的 5 行解決方案類似於 -
for i in range(4):
Dev.step(2*i+6)
for a in range(3):
Dev.turnLeft()
Dev.step(i+2)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.