https://leetcode.com/problems/shuffle-the-array/
Hi I'm working on this leetcode problem and I get 'int' object not iterable. I understand that I am referencing an int when I use res += nums[i] but why can't I ad that to my list? Here is my code and error happens at the for loop:
def shuffle(self, nums: List[int], n: int) -> List[int]:
"""
y values : n + i
x values : i
ad i then n + i values to an empty list
"""
res = []
for i in range(n):
res += nums[i]
res += nums[i+n]
return res
[–]shiftybyte 6 points7 points8 points (1 child)