You are trying to use d
as an integer:
for l in range (a, d+1):
by adding 1
to it, but you made it a string:
d = str(input("Ange ett siffervärde: "))
Make all your inputs integers instead:
a = int(input("Ange ett siffervärde: "))
b = int(input("Ange ett siffervärde: "))
c = int(input("Ange ett siffervärde: "))
d = int(input("Ange ett siffervärde: "))
Next, your for
loop clobbers the l
variable:
l = (a+b+c+d)
for l in range (a, d+1):
It isn't clear what you want to do in the loop, but the sum of a
, b
, c
and d
is now lost as l
is used as a loop variable too.
If you wanted to have decimals, you can use float()
instead of int()
, but note that range()
can only work with integers!
If you wanted to print the 4 numbers in a loop, then create a list first and loop directly over the list:
a = float(input("Ange ett siffervärde: "))
b = float(input("Ange ett siffervärde: "))
c = float(input("Ange ett siffervärde: "))
d = float(input("Ange ett siffervärde: "))
lst = [a, b, c, d]
for number in lst:
print(number)
or combine looping with asking for the number and printing it:
lst = []
for count in range(4):
number = float(input("Ange ett siffervärde: "))
print(number)
lst.append(number)
This asks for a number four times, prints the given number, and then adds that number to a list for later use.