Create your own (loop)


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/loops/exercises/create-your-own?action=lesson_resume

<In what way does your code behave incorrectly? Include ALL error messages.>
I am satisfied with my loop and result as it works correctly. Though, the only problem I have is that the interpreter also prints out “None” and not JUST my print statement. Is there a way to fix that?

<What do you expect to happen instead?>

```python

string = [“A”, “B”, “C”]
#String with 2 or 0 of the same characters
def first_recurring_string(b):
#create an empty directory to store the values in
counts = {}
for char in string:
#loops through the string to see if recurrence has happend
if char in counts:
#if a character is in counts, then we will return char
return char
else:
#returns the value (char) in counts
counts[char] = 1
#if a value hasn’t occured more than once, print;
print “No value has occured more than one time”

print first_recurring_string(string)

<do not remove the three backticks above>

#2

Why the heck does it look like that. I followed the instructions :face_with_raised_eyebrow:


#3

None is the return value of the print function and can be ignored. It is console related and has nothing to do with our code.


#4

Okay, thanks! Good to know :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.