## Monday, November 9, 2020

Solution Exercise 83: python program to find the first repeated character within a given string #### Exercise 83 *

Write a Python program as function that takes as parameter a string s and which returns the first repeated character in the string s. Example: if s = "django framework", the fuction returns the character 'a'

#### Solution

``````# create a function to test if given character is repeated within a given string
def isRepeated(s,c):
counter = 0
for x in s:
if x == c:
counter = counter + 1
if counter >= 2:
return True
else:
return False
# function which determines the first repeated character
def firstRepeated(s):
repeated = ''
for x in s:
if isRepeated(s,x):
repeated = x
break
return repeated

# Example
s = "django framework"
print("The first repeated character is : " , firstRepeated(s))
# The output is: 'The first repeated character is :  a'``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 