Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a moment to download the script and note the contents. You will find a test string and a list. Both contain entries from the file
a moment to download the script and note the contents. You will find a test string and a list. Both contain entries from the file etcpasswd:
arthur:x:::Arthur Smith:homearthur:binbash
where:
arthur username
x indicates encrypted password
UID
GID
Arthur Smith Comment
homearthur home directory
binbash shell
Add the following to qpasswd.py:
A Docstring with your name and student ID
A new function. Your function should:
a Take a string as an argument such as teststrn
b Split the string by the appropriate character
c If the userid is the same as groupid, return True.
d Otherwise, return False.
Inside the main block delete the
Call your function with teststrn as an argument. Print the result, and verify that it is correct.
Next, use a loop to iterate through each line of frompasswd.
For each iteration of the loop print either:
a "arthur is a regular user" for example, for the user arthur if your function returns True. Or:
b "arthur is not a regular user" if your function returns False.
c Finally, as a comment answer the following:What happens if the number of fields in a string changes? For example, if the first line has fields but the next line has What error will you get? How can you prevent this from causing an error?
Save your changes to the file and attach it below for evaluation.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started