-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc78e20
commit 3952cfa
Showing
1 changed file
with
7 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
list = [] | ||
num = int(input("Enter size of list: \t")) | ||
for n in range(num): | ||
numbers = int(input("Enter any number: \t")) | ||
list.append(numbers) | ||
list = [int(input("Enter any number: \t")) for _ in range(num)] | ||
|
||
x = int(input("\nEnter number to search: \t")) | ||
|
||
found = False | ||
|
||
for i in range(len(list)): | ||
if list[i] == x: | ||
found = True | ||
print("\n%d found at position %d" % (x, i)) | ||
break | ||
if not found: | ||
print("\n%d is not in list" % x) | ||
for position, number in enumerate(list): | ||
if number == x: | ||
print(f"\n{x} found at position {position}") | ||
else: | ||
print(f"list: {list}") | ||
print(f"{x} is not in list") |