diff --git a/answer1.py b/answer1.py new file mode 100644 index 0000000..26270fb --- /dev/null +++ b/answer1.py @@ -0,0 +1,8 @@ +lst = input() + +l = [1, 2, 3, 4, 5] +def rotate(l, n): + return l[-n:] + l[:-n] + +print(rotate(l, -2)) +print(rotate(l, 2)) \ No newline at end of file diff --git a/answer2.py b/answer2.py new file mode 100644 index 0000000..2e5cd30 --- /dev/null +++ b/answer2.py @@ -0,0 +1,11 @@ +import collections + +sentence = input("type a sentence: ") + + +sentence = sentence.lower() +sentence = sentence.replace(" ","") + +print(collections.Counter(sentence)) + + \ No newline at end of file diff --git a/answer3.py b/answer3.py new file mode 100644 index 0000000..25efb88 --- /dev/null +++ b/answer3.py @@ -0,0 +1,27 @@ +#collecting inputs: +word1 = set(input("type any word: ").lower()) +word2 = set(input("type another word: ").lower()) + +#shared letters as a sorted string +common = sorted(set(word1 & word2)) +incommon_str = ''.join (list (map (str, common))) + +#Letters unique to word 1 as a sorted string: +unique_to1 = sorted(set(word1 - word2)) +unique1 = ''.join (list (map (str, unique_to1))) + +#Letters unique to word 2 as a sorted string: +uinque_to2 = sorted(set(word2 - word1)) +unique2 = ''.join (list (map (str, uinque_to2))) + +#creating a list of the above strings +lst = [] +lst += [incommon_str] +lst +=[unique1] +lst +=[unique2] + +# extracting the requested output: +print("the output is:" + str(lst)) + + +