This is a followup to https://github.com/TheAlgorithms/Python/pull/4973#issuecomment-933117382
As per given suggestion, I've added type hints to certain methods that don't have them. I have also added documentation and example doctests as a usage example for (most of) those that don't have them.
I have also added another test case following the previous test case's format. I noticed that the existing test case from previous pull request might be redundant with the ones I've made, so I decided to create a specific situation where the linked list would have to keep different kinds of data types for each node, in `test_singly_linked_list_2` test function.
Some minor changes in strings has been done to keep things consistent with other parts of the document. If it is undesirable, please let me know.
* Precision must be a nonnegative integer
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* added __len__ function
Added a function to count number of nodes in linked list
* Updated __len__ method
used snake_case instead of camel case
* Add tests to __len__()
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update singly_linked_list.py
printing current.data rather than node address in __repr__ for a more readable print statement
* eval(repr(c)) == c
The output of `__repr__()` _should look like a valid Python expression that could be used to recreate an object with the same value_.
https://docs.python.org/3.4/reference/datamodel.html#object.__repr__
* += --> +
* Improved Singly Linked List
Added String Representations of Nodes and Linked Lists
Added support for indexing and changing of Node data using indices.
* Added a few comments to Linked Lists
* Reformatted to conform to PEP8
* Added from_sequence.py
Convert a Python List to Linked List comprising of Nodes and return head.
* Added print_reverse.py
Recursive program to print the elements of a Linked List in reverse.
* Change 'is not None' for more Pythonicness