Skip to content

Add Two Numbers #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Two Numbers #6

wants to merge 1 commit into from

Conversation

bumbuboon
Copy link
Owner

return current_node
```
- not ではなく is Noneと書くべきではないのだろうか?
- not l1, not l2はis None だがnot carry はis 0である。そこを示した方がわかりやすい気がする
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここらへんは、派閥ありますね。周りに聞いて合わせましょう。
Google Style Guide は is not None 派。
https://google.github.io/styleguide/pyguide.html#2144-decision
Pep8 はどちらでもいいのかしら。
https://peps.python.org/pep-0008/#programming-recommendations:~:text=Also%2C%20beware%20of%20writing%20if%20x%20when%20you%20really%20mean%20if%20x%20is%20not%20None

```python
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
dummyHead = ListNode(0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

変数名は lower_snake で書くことをおすすめいたします。

https://peps.python.org/pep-0008/#function-and-variable-names

Variable names follow the same convention as function names.

https://google.github.io/styleguide/pyguide.html#316-naming

local_var_name

LeetCode で指定されているものについては、例外として扱ってよいと思います。


while node1 is not None or node2 is not None or carry != 0:

node1_val = node1.val if node1 is not None else 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この周辺、インデントでタブとスペースが混ざっているように思います。スペースでインデントすることをおすすめいたします。

https://peps.python.org/pep-0008/#indentation

Use 4 spaces per indentation level.

https://google.github.io/styleguide/pyguide.html#34-indentation

Indent your code blocks with 4 spaces.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。なんとなく使っていたのですがTabはエディタなどが違うと異なって表示されるためspaceが推奨されているのですね。これから注意したいと思います。

elif node2 is None:
val = node1.val + carry

carry = val//10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

二項演算子の両隣にスペースを空けるか空けないか、ソースコード間で統一することをおすすめいたします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants