Перейти к содержимому
  • 0
Taner

Python вылет по непонятной причине.

Вопрос

Решил потренироваться в python и написать игру типа наперстков. И вроде написал и запускается, но когда доходишь до самой игры (28 строка) программа крашится.

Циклы удалял, брейки тоже, с бубном танцевал, компьютер материл, через дебагер пробовал вообще все ломается.

Может кто подскажет в чем проблема?

Вот сам код:

import random
import sys
#Greetings
print("Welcome to the thimbles!")
print("Enter a command: ")
print("H - help")
#Game start
while True: #Main menu cycle
	UInput = input()
	if UInput == "q" or UInput == "Q": break   #Exit function

	if UInput == "H" or UInput == "h" or UInput == "Help" or UInput == "help":  #Help function
		print("To start the game, enter G. To call this list, enter H. To exit, enter Q")
		print("Enter a command: ")

	elif UInput == "g" or UInput == "G" or UInput == "game" or UInput == "Game": #Game start
		print("Well well, look who is come to me! Do you wana play with me? (y/n)")
		while True: #Game menu cycle

			UInput = input() #User input

			if UInput == "q" or UInput == "Q": break 

			G = 10 #Start Gold count

			if UInput == "y":
				print("Well then sitdown here and give me some of your's gold. If you win, you will get doubled of them. ")
				while True: #Game cycle
					GInGame = input("How much gold you will give to the stranger? (You have " + G + " gold)")
					if GInGame > G:
						print("You don't have this amount of gold")
						GInGame = int(input("How much gold you will give to the stranger? (You have " + G + " gold)"))

					G = G - GInGame #Remove gold what now in game

					RightCup = random.uniform(1, 3) #Random generator for game
					CCup = input("What cup you will chose? (1-3) ")
					if CCup == RightCup: #Player chose right cup
						GInGame = GInGame * 2 #Gold in game multiplise by 2
						print("You luky! Here your's " + GInGame + "gold.")
						G = G + GInGame #Adding gold to the sorce
						GInGame = 0 #Reset in game gold
					else: #Player lose
						print("I won.")
						GInGame = 0 #Reset in game gold
					print("Play agan? (y/n)") #Play game again
					if UInput == "n":
						break
					else:
						print("Ok then.")
			else:
				print("If no, then get out of here!")
				break

	else:
		print("No such command.")
		print("Enter a command: ")

 

My_game.py

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах

Рекомендуемые сообщения

Надо приводить к нужному типу при обработке. 'blabla' + str(G)

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах

Да это помогло, спасибо.

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить на вопрос...

×   Вы вставили отформатированное содержимое.   Удалить форматирование

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отобразить как ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.


×
×
  • Создать...