I am solving Fizz Buzz on leetcode and I am facing this issue of getting single quotes instead of double quotes. Code:
class Solution:
def fizzBuzz(self, n: int) -> List[str]:
answer = []
for number in range (1, n+1):
if number % 5 == 0 and number % 3 == 0:
answer.append("FizzBuzz")
elif number % 5 == 0:
answer.append("Buzz")
elif number % 3 == 0:
answer.append("Fizz")
else:
answer.append(f"{number}")
print(answer, end='')```
Output:
Runtime: 59 ms
Your input
3
stdout
['1', '2', 'Fizz']
Output
[]
Expected
["1","2","Fizz"]
You don't have to print it you have to return the output on coding platform
change this
print(answer, end='')
to this
return answer
interpretation
stdout << what is output on stdout/console/command line
['1', '2', 'Fizz'] << printed value of array
Output << what is returned
[] << Empty array
Expected << expected return
["1","2","Fizz"] <<< expected to return this array
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.