3
u/Dzhama_Omarov Aug 27 '25
Iterable is an object that consists of smaller objects which have an order. Integer is just an object that consists of a number and thats it. Meanwhile things like lists, strings, tuples etc are a collection of other objects (integers, booleans, even iterables as well). I want to point out two things:
There are things like sets. Which are collections of other objects, but they have no strict order, ie unordered. They are not iterables
things like strings, you may see as a singular object (it’s basically a word, or a text) but in fact its a collection of letters
Im not familiar with deque function, but i guess it requires an iterable to go over its contents and you supply this function with 3, which is an integer and not an iterable
3
Aug 27 '25 edited Aug 27 '25
a/ Don't post screenshots....for the love of god. b/ ChatGpt and especially claude.ai are incredible learning tools. Paste your code in, with the error, and ask it to explain what went wrong. The real benefit comes from being able to post followup questions without having to wait.
3
1
1
u/gigsoll Aug 27 '25
You are passing an integer into your function but treat it like a list. You need to either change your function call to pass an iterable or function to treat input as an integer. A good help for you may be mypy or pyright in combination with type hints. If you want to create a deque, you need to pass an iterable (list or tuple)
3
Aug 27 '25
[removed] — view removed comment
3
u/gigsoll Aug 27 '25
The longer I learn python, more I am thinking about strongly typed language
2
u/FoolsSeldom Aug 27 '25
I know you know Python is a strongly typed language, but I also know what you mean.
1
u/calculus_is_fun Aug 27 '25
lots of problems here.
You named a function "f" while this is common in mathematics, you should avoid this in a programming context, name the function based on it's task.
The local variable q is unused.
A deque (short for double ended queue) is a structure that is an ordered set of elements where you can only interact with the ends. Try using
deque((n)),deque([n]), ordeque([0 for i in range(n)])
1
u/tb5841 Aug 27 '25
What are you trying to use deque for?
Just cut that line and the import out of your code, nd your function will work fine.
1
u/hari3mo Aug 27 '25
You are passing an integer as input into a function that requires an iterable. You can do f([3])
1
11
u/JeLuF Aug 27 '25
What is your question?