Question
Code: def mycheck(L): flag=True; counter=0; n=len(L); while(flag): if(L[i]%2==0): flag=False; if(counter a[i+1]): flag=False; counter=counter+1; if(counter==n): break; return flag; Python: Write code for function main, which gets
Code:
def mycheck(L): flag=True; counter=0; n=len(L); while(flag): if(L[i]%2==0): flag=False; if(counter
Python:
Write code for function main, which gets the user to enter one integer, call it num.
Using error handling, if the entry is not a number, shown an error message.
Check the num is a positive number. If it is, use a for loop to create a list where the for loop runs for num number of times. Each time, ask the user for a number (integer), then add it to the end of a list.
Once the for loop ends, call the mycheck function from the previous question passing it the List, and test its return value: if not true, display some message, else ask the user for a filename and write the list content to the file. When opening the file to write the data open it in writing mode then close it when done.
Call main at the end.
Do not add any comments or code not required by this question. This will cause loss of points.
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