Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected output
#1
arr=[1,2,3,9]
ip=arr[0]
im=arr[3]
srcfor=ip+im
i=8
while srcfor>=0:
    if srcfor<8:
        ip+=1
        srcfor=ip+im
        if srcfor==i:
            break
    else:
        if srcfor<8:
            im-=1
            srcfor=ip+im
            if srcfor==i:
                break
print (srcfor)

Hi, I'm new of the Forum. The code that you can see at the top of the thread is a my experiment. I was searching to create a code that into an array search a couple of numbers that if sum, the result would be 8. So I tried with some while loops and if statements, but it don't give me any output, Please Help Me.

Huh
Reply


Messages In This Thread
Unexpected output - by Lorenzo173 - Dec-20-2017, 10:08 PM
RE: Unexpected output - by j.crater - Dec-20-2017, 10:23 PM
RE: Unexpected output - by Lorenzo173 - Dec-25-2017, 07:07 PM
RE: Unexpected output - by j.crater - Dec-25-2017, 10:31 PM
RE: Unexpected output - by Lorenzo173 - Dec-26-2017, 09:20 AM
RE: Unexpected output - by Lorenzo173 - Jan-11-2018, 07:26 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020