Question
Can someone determine how the following Java code would look in python? //Assuming EMP_ID maximum can hold 7 alphanumeric characters import java.util.Scanner; public class EMPValidation
Can someone determine how the following Java code would look in python?
//Assuming EMP_ID maximum can hold 7 alphanumeric characters
import java.util.Scanner;
public class EMPValidation {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter Emp ID: ");
String empID = in.nextLine();
System.out.println("IsValid: "+ isValid(empID));
}
public static boolean isValid(String empID){
if ((empID.length()<1) || (empID.length()>7)) {
return false;
}
else {
String empPattern= "^[a-zA-Z0-9]*$";
return empID.matches(empPattern);
}
}
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