antitheft159
commited on
Commit
•
96ea639
1
Parent(s):
c0b8b1c
Upload wordjumble-1-0.ipynb
Browse files- wordjumble-1-0.ipynb +1 -0
wordjumble-1-0.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9635183,"sourceType":"datasetVersion","datasetId":5882803}],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import random\n\ndef scramble_word(word):\n word_list = list(word)\n random.shuffle(word_list)\n return ''.join(word_list)\n\ndef play_game(words):\n score = 0\n for word in words:\n scrambled_word = scramble_word(word)\n print(f\"Scrambled word: {scrambled_word}\")\n\n guess = input(\"Your guess: \")\n\n if guess.lower() == word.lower():\n print(\"Correct!\\n\")\n score += 1\n else:\n print(f\"Wrong! The correct word was '{word}'.\\n\")\n\n print(f\"Game over! Your final score is {score} out of {len(words)}.\")\n\nwords = [\"python\", \"developer\", \"chatgpt\", \"algorithm\", \"keyboard\"]\n\nplay_game(words)","metadata":{},"execution_count":null,"outputs":[]}]}
|