Skip to content

Commit 98caa54

Browse files
committed
added the stuff
1 parent 5f2b2b3 commit 98caa54

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

Day-02/examples/01-string-split.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
11
text = "Python is awesome"
22
words = text.split()
33
print("Words:", words)
4+
5+
6+
arn = "arn:aws:iam::623917384971:user/devops-sudhamsh/arbitary-sudhamsh-test-string"
7+
# username = arn.split('/')
8+
username = arn.split('-')
9+
#here split is the built-in function that is used to split a string into a list of substrings.
10+
print(username)
11+
# This Python code takes an AWS IAM (Identity and Access Management) user's ARN (Amazon Resource Name) as input and extracts the username from the ARN.
12+
13+
# Here's a breakdown of the code:
14+
15+
# arn is a string that represents an AWS IAM user's ARN. ARN stands for Amazon Resource Name and is a way to uniquely identify AWS resources.
16+
17+
# arn.split('/') is used to split the arn string into a list of substrings using the forward slash ("/") as the delimiter. The forward slash is commonly used to separate components of an ARN.
18+
19+
# username is assigned the value of arn.split('/'). After splitting the arn string, the username variable should contain a list of substrings, and the username should be one of these substrings.
20+
21+
# print(username[1]) prints the second element (index 1) of the username list. In an ARN, the username typically appears as the second element after splitting by slashes. So, this line of code prints the IAM username extracted from the ARN.
22+
23+
# So, if the arn variable contains the ARN you provided ("arn:aws:iam::623917384971:user/devops-sudhamsh"), this code would print "user/devops-sudhamsh," which is the IAM username.

Day-02/examples/01-string-strip.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
text = " Some spaces around "
2+
# print("Original text:", text)
3+
#Returns a trimmed version of the string
24
stripped_text = text.strip()
35
print("Stripped text:", stripped_text)

Day-02/examples/02-float.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
print("Division:", result4)
1717

1818
# Rounding
19-
result5 = round(3.14159265359, 2) # Rounds to 2 decimal places
19+
result5 = round(3.14159265359, 3) # Rounds to 2 decimal places
2020
print("Rounded:", result5)

Day-02/examples/03-regex-match.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import re
22

3-
text = "The quick brown fox"
3+
text = "quick brown fox"
44
pattern = r"quick"
55

6-
match = re.match(pattern, text)
7-
if match:
8-
print("Match found:", match.group())
6+
catch = re.match(pattern, text)
7+
if catch:
8+
print("Match found:", catch.group())
99
else:
1010
print("No match")

0 commit comments

Comments
 (0)