Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Assignment
#8
(Oct-06-2016, 12:58 AM)tinabina22 Wrote:  #1. Create a loop that goes through each item in the password list
#  simplest way to loop through a list is: for i in range(len(NAMEOFLIST))

The simplest way to loop through each item in the password list is
for item in NAMEOFLIST:
    print(item)
As passwords is a list of list you can do the loop like this
passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]]
for site, password in passwords:
    print(site, password)
Output:
yahoo XqffoZeo google CoIushujSetu
In the last post the reason the code starts all over at #1 after inputting a password is because there is no code to tell it to do anything but go back to the while loop.
Reply


Messages In This Thread
Assignment - by tinabina22 - Oct-06-2016, 12:58 AM
RE: Assignment - by Larz60+ - Oct-06-2016, 03:03 AM
RE: Assignment - by Skaperen - Oct-06-2016, 04:36 AM
RE: Assignment - by sparkz_alot - Oct-06-2016, 01:35 PM
RE: Assignment - by tinabina22 - Oct-06-2016, 09:54 PM
RE: Assignment - by nilamo - Oct-06-2016, 09:59 PM
RE: Assignment - by tinabina22 - Oct-06-2016, 11:10 PM
RE: Assignment - by Yoriz - Oct-06-2016, 11:35 PM
RE: Assignment - by tinabina22 - Oct-06-2016, 11:36 PM

Forum Jump:

User Panel Messages

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