Python Forum
Help with function and sep( , ) value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with function and sep( , ) value
#11
Good job on remove_value()!

As for reverse():
1) I'm not sure what you're trying to accomplish in lines 32-33. It appears that if the variable is equal to -1, you are reassigning it the same value of -1. From the assignment and your comment in the program, it seems like the only check you need here is whether the entered number is less than 2.

2) There are problems with your approach in your for loop on lines 45-50. Keep in mind that when you use "for element in my_list:", you are iterating through the values in the list ('e', 'd', 'u', 'd' in the case of str_list6). That means the element variable is a string, and you therefore can't add or subtract the integer value 1. If your plan is to iterate through a list in reverse order, you can do that using range() and the length of the list. Just to illustrate, this code would print the values from my_list one at a time in reverse order:
for i in range((list_length - 1), -1, -1):
    print(my_list[i])
Reply


Messages In This Thread
Help with function and sep( , ) value - by drewbty - May-31-2020, 09:20 AM
RE: Help with function and sep( , ) value - by GOTO10 - Jun-02-2020, 12:34 PM

Forum Jump:

User Panel Messages

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