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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!