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/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 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 diff --git a/test8766 b/test8766 new file mode 100644 index 0000000..b2a9541 --- /dev/null +++ b/test8766 @@ -0,0 +1,4 @@ +new +new +new +