I have written a code using while loop. However I have written the code successfully but it is not efficient. Please see the while loop: -
struct_type = { 1:'slab', 2:'beam', 3:'column', 4:'footing' }
z = int(input("Enter the structure type as 1-slab,2-beam,3-column,4-footing"))
while (z != 1 and z != 2 and z != 3 and z != 4):
print("Invalid Structure type")
z = int(input("Enter only: 1-slab,2-beam,3-column,4-footing"))
print(z)
How to write this while loop more efficiently? For example
while (z != [1, 2, 3, 4]):
or
while (z != range(1:5)):
But both these give errors. please help in writing this while loop more efficiently.
while z not in [1,2,3,4]:?