Skip to content

Commit 4300862

Browse files
authored
Merge pull request #24 from easyawslearn/python_input_example
python input
2 parents f766d3a + 71c591f commit 4300862

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

python_input/python_input.py

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
user = input("enter a any key : >>>") #input from user
2+
3+
if (type(user)) == int: # chack type
4+
print("it is a number")
5+
else:
6+
print("it is not a number")
7+
8+
# ///////output/////////
9+
# enter a any key : >>>q
10+
# it is not a number
11+
12+
13+
user = input("enter a number:>>>>") #input from user
14+
try:
15+
val = int(user) # pass if number
16+
except ValueError:
17+
print("that is not a number") # if not message print
18+
19+
# ///////output/////////
20+
# enter a number:>>>>q
21+
# that is not a input
22+
23+
24+
user = input("enter a number:>>") #input from user
25+
if user.isdigit():
26+
print("it is a digit")
27+
else:
28+
print("it is not a digit:")
29+
30+
# ///////output/////////
31+
# enter a number:>>1
32+
# it is a digit
33+
34+
# enter a number:>>a
35+
# it is not a digit:
36+
37+
38+
def user():
39+
choice ="worng"
40+
while choice.isdigit() == False:
41+
choice = input("plese enter a number:")
42+
return int(choice)
43+
user()
44+
45+
# output 1
46+
# plese enter a number:12
47+
48+
# output 2
49+
# enter a number:>>q
50+
# it is not a digit:
51+
52+
53+
def user():
54+
choice = "worng"
55+
acceptable_rang = range(0,10)
56+
with_rang = False
57+
58+
while choice.isdigit() == False or with_rang==False:
59+
choice = input("enter a number (0,10):")
60+
61+
if choice.isdigit() == False:
62+
print("sorry this is not a digit")
63+
64+
if choice.isdigit() == True:
65+
if int(choice) in acceptable_rang:
66+
with_rang = True
67+
else:
68+
with_rang = False
69+
70+
return int(choice)

0 commit comments

Comments
 (0)