list_ = [6,8,4,5,2] I = 0 J = 999 while I < 5: J = 0 while J < 4: if list_[J]> list_[J+1]: # This if statement will check values in list and then... list_[J],list_[J+1] = list_[J+1],list_[J] # swap the values if the item after it has a lesser value J += 1 I += 1 else: J += 1 I += 1 print(list_)Without knowing exactly what the output should be I won't know if its correct, but judging by the steps you are stuck at, it looks like it wants you to swap values in a list.
while loop help
Messages In This Thread |
while loop help - by jhall710 - Apr-25-2017, 09:36 PM
RE: while loop help - by Larz60+ - Apr-26-2017, 12:07 AM
RE: while loop help - by jhall710 - Apr-27-2017, 01:15 AM
RE: while loop help - by Larz60+ - Apr-27-2017, 01:58 AM
RE: while loop help - by smbx33 - Apr-27-2017, 07:28 AM
RE: while loop help - by jhall710 - May-07-2017, 08:05 PM
RE: while loop help - by ichabod801 - May-07-2017, 09:54 PM
RE: while loop help - by jhall710 - May-08-2017, 12:28 AM
RE: while loop help - by ichabod801 - May-08-2017, 01:12 AM
RE: while loop help - by jhall710 - May-08-2017, 02:20 AM
RE: while loop help - by smbx33 - May-08-2017, 08:59 PM
RE: while loop help - by volcano63 - May-08-2017, 09:25 PM
RE: while loop help - by ichabod801 - May-08-2017, 11:57 AM
RE: while loop help - by nilamo - May-08-2017, 04:41 PM
RE: while loop help - by volcano63 - May-08-2017, 08:00 PM
RE: while loop help - by ichabod801 - May-08-2017, 09:37 PM
|
Users browsing this thread: 1 Guest(s)