bratk
1
def add_greetings(names):
for name in names:
count = 0
print("Hello, " + name)
count += 1
print(add_greetings(["Owen", "Max", "Sophie"])
Output: Hello Owen
Hello Max
Hello Sophie
None
What’s Wrong with my code, Why none occurs despite of count definition?
tgrtim
2
A function that completes its execution without output e.g. no return
will always return None
. Why might this be printed?
4 Likes
bratk
3
I found this error. Despite adding the return statement “return names” code is appearing with a different Output: Hello Owen,
Owen
tgrtim
4
What did you want to print? Does your code reflect that? It won’t be printing an output unless you asked for one.
1 Like
bratk
5
The output must be printed like this: Hello Owen
Hello Max
Hello Sophie
Within a List
tgrtim
6
What seciton of your code is responsible for printing each of these lines? Is it the same part, or more than one?