-
Notifications
You must be signed in to change notification settings - Fork 0
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
74c3e33
commit f3e359c
Showing
4 changed files
with
36 additions
and
21 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
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,8 +1,16 @@ | ||
# Checking if a file exists | ||
# Create a list with pseudo-random numbers | ||
# Check if all elements in this list are unique | ||
|
||
import os | ||
import random as rd | ||
|
||
if os.path.isfile("file.txt"): | ||
print("File exists!") | ||
my_list = [] | ||
|
||
for i in range(0,10): | ||
my_list.append(rd.randint(0,100)) | ||
|
||
print(my_list) | ||
if len(my_list) == len(set(my_list)): | ||
print("All elements in this list are unique!") | ||
else: | ||
print("File does not exists!") | ||
print("Not all elements in this list are unique!") | ||
|
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,8 +1,2 @@ | ||
# Checking if a file exists | ||
# Removing the occurrence of an item in a list | ||
|
||
import os | ||
|
||
if os.path.isfile("file.txt"): | ||
print("File exists!") | ||
else: | ||
print("File does not exists!") |
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,8 +1,2 @@ | ||
# Checking if a file exists | ||
# Flattening a nested list | ||
|
||
import os | ||
|
||
if os.path.isfile("file.txt"): | ||
print("File exists!") | ||
else: | ||
print("File does not exists!") |