Summary
Create a basic singly linked list structure and a helper to build one from a Python list.
Problem statement
Implement a simple Node and LinkedList structure and write the function build_linked_list(values). Given a Python list of values (possibly empty), build a singly linked list with the same order and return the LinkedList instance. The LinkedList must implement __str__ to produce a string using '->' between values (e.g. '1->2->3'). For an empty list return an empty string when the LinkedList is converted to str().
Task
Implement a function to construct a singly linked list from a Python list of values and provide a readable string representation.
Examples
Build a list with three elements
Input
[1, 2, 3]
Output
1->2->3
Explanation
Nodes are created in the same order as the input list and linked forward.
Input format
A Python list of values, e.g. [1, 2, 3].
Output format
A LinkedList instance whose str() is either '' (empty) or values joined by '->'.
Constraints
Do not use Python built-in linked-list libraries. Values can be any type that supports str().
Samples
Sample input 0
[5]
Sample output 0
5
Explanation 0
A single-node list shows just the value.
AI assistant
Ask me anything!
Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.
Chat history is temporary and will not be saved.
Free preview includes 1 Teach Theory response and 1 AI hint on each of the first 3 lessons in this module.