Skip to content
Snippets Groups Projects
Commit 3202f16e authored by Andreas Fischer's avatar Andreas Fischer
Browse files

Added Clean Code exercise

parent a47b7c34
Branches master
No related tags found
No related merge requests found
b="00123456"
i=0
temp1=0
while i<len(b):
a=b[i]
a=int(a)
temp1=temp1+a
i+=1
print(temp1)
c=input("Please enter a number: ")
j=0
temp2=0
while j<len(c):
d=c[j]
d=int(d)
temp2=temp2+d
j+=1
print(temp2)
x=temp1-temp2
print("The difference is:", x)
def myfunc(values, value, next):
"""
This function will search an item in a list of values and return the neighbouring value -- either the successor or the predecessor.
"""
# First: find the position of value
i = -1
for j in range(len(values)):
v = values[j]
if v == value:
i = j
# If next == True get the successor
if next:
if i < len(values) - 1:
k = i + 1
return values[k]
else:
if i > 0:
l = i - 1
return values[l]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment