From 3f3ced6a2d2342e39d46c1290da9213235f9455a Mon Sep 17 00:00:00 2001 From: Oded3012 <96193529+Oded3012@users.noreply.github.com> Date: Thu, 7 Apr 2022 19:25:46 +0300 Subject: [PATCH 1/3] Create new1 --- new1 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 new1 diff --git a/new1 b/new1 new file mode 100644 index 0000000..96fccda --- /dev/null +++ b/new1 @@ -0,0 +1,3 @@ +hEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-World +hEllo-World +vhEllo-WorldhEllo-WorldhEllo-WorldhEllo-WorldhEllo-World1323213131321334543543543543543534543 From 131f3e4e461c37b41841616471bd95af5047ba02 Mon Sep 17 00:00:00 2001 From: oded Date: Sun, 17 Apr 2022 16:39:42 +0300 Subject: [PATCH 2/3] new --- test8766 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test8766 diff --git a/test8766 b/test8766 new file mode 100644 index 0000000..b2a9541 --- /dev/null +++ b/test8766 @@ -0,0 +1,4 @@ +new +new +new + From b38b766242ee41635be6e1b1f73c4e50cfb831c7 Mon Sep 17 00:00:00 2001 From: oded Date: Sun, 24 Apr 2022 21:16:04 +0300 Subject: [PATCH 3/3] Fix Code --- StateCap.py | 68 ++++++++++++++++++++--------------------------------- strings.py | 61 ++++++++++++++++++++--------------------------- 2 files changed, 51 insertions(+), 78 deletions(-) diff --git a/StateCap.py b/StateCap.py index 73fcf7f..53f4467 100644 --- a/StateCap.py +++ b/StateCap.py @@ -11,9 +11,8 @@ handle that? """ -import sys -import pytest +import sys STATES_CAPITALS = { 'Alabama' : 'Montgomery', @@ -68,51 +67,34 @@ 'Wyoming' : 'Cheyenne', } - -def capital_of_Idaho(): - # Your code here - pass +def capital_Idaho(): + print(STATES_CAPITALS['Idaho']) +capital_Idaho() +pass def all_states(): - # Your code here - pass + print(STATES_CAPITALS.keys()) +all_states() +pass def all_capitals(): - # Your code here - pass + print(STATES_CAPITALS.values()) +all_capitals() +pass def states_capitals_string(): - # Your code here - pass - - - -def get_state(capital): - pass - - - -def test_state_to_capital(): - assert 'Cheyenne' == STATES_CAPITALS['Wyoming'] - - -def test_state_to_capital_unknown(): - with pytest.raises(KeyError): - STATES_CAPITALS[''] - - -def test_capital_to_state(): - assert 'Wyoming' == get_state('Cheyenne') - - -def test_capital_to_state_unknown(): - with pytest.raises(KeyError): - get_state('') - - -def main(): - return pytest.main(__file__) - + lst = STATES_CAPITALS.keys() + sort = sorted(lst) + print(sort) +states_capitals_string() +pass + +def get_state(): + stat = input('Provide Capital:') + for st, cap in STATES_CAPITALS.items(): + if cap.lower() == stat: + results = st+ " " +cap + print(results) +get_state() +pass -if __name__ == '__main__': - sys.exit(main()) diff --git a/strings.py b/strings.py index 7915338..fd7d5d7 100644 --- a/strings.py +++ b/strings.py @@ -9,39 +9,30 @@ Example: ['mont', 'y py', 'thon', 's fl', 'ying', ' cir', 'cus'] ### git comment """ -import pytest -def no_duplicates(a_string): - pass - - -def reversed_words(a_string): - pass - - -def four_char_strings(a_string): - pass - - -def test_no_duplicates(): - s = 'monty pythons flying circus' - assert no_duplicates(s) == ' cfghilmnoprstuy' - - -def test_reversed_words(): - s = 'monty pythons flying circus' - assert reversed_words(s) == ['circus', 'flying', 'pythons', 'monty'] - - -def test_four_char_strings(): - s = 'monty pythons flying circus' - assert four_char_strings(s) == ['mont', 'y py', 'thon', 's fl', 'ying', ' cir', 'cus'] - - -def main(): - return pytest.main(__file__) - - -if __name__ == '__main__': - main() - +def no_duplicates(): + str = 'monty pythons flying circus' + remove = ''.join(sorted(set(str), key=str.index)) + sort = ''.join(sorted(remove)) + print(sort) +no_duplicates() +pass + +def reversed_words(sentence): + # first split the string into words + words = sentence.split(' ') + # then reverse the split string list and join using space + reverse_sentence = ' '.join(reversed(words)) + # finally return the joined string + return reverse_sentence +if __name__ == "__main__": + input = 'monty pythons flying circus' + print(reversed_words(input)) +pass + +def four_char_strings(): + str1 = ['monty', 'pythons', 'flying', 'circus'] + for i in str1: + print(i[:4]) +four_char_strings() +pass