Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why is it crushing ?
#3
I modified your code to use in Python 3 and ran it. Namely raw_input() is input() in Python 3. And print is a function, not a statement, so you use it like print("This is printed!"). The code is:

import time

global coins
global common
global garbage
global uncommon
common = 0
uncommon = 0
garbage = 0
coins = 100


def start():
    print("Hello my friend!")
    name = input("what's your name :")
    print("Welcome, " + name + "!")
    print("This game is just like Tatsumaki Discord Bot fishing system, i hope that you enjoy it.")
    print("the gole of the game is to collect as much fishs as possible then selling them for coins.")
    print("Common fishs worth 12 coins/uncommon fishs worth 20 coins/garbage worth 8 coins.")
    print("you have to pay 10 coins as a fee for fishing.")

    choice = input("Do you want to play Y/N ?:")
    if choice == "Y":
        print("To fish you have to use the command fish")
        begin()
    if choice == "N":
        print("Goodbye")
        time.sleep(2)


def begin():
    global common
    global garbage
    global uncommon
    global coins
    print("Let's start!")
    if coins > 500:
        print("You have won the game!")
        play = input("Do you want to play again?:")
        if play == "Y":
            begin()
        if play == "N":
            print("Congrazts again")
            time.sleep(2)
    fish = input("Do you want to fish ?:")
    if fish == "fish":
        print("You caught a common fish!")
        common = common + 1
        coins = coins - 10
        print("You currently have, " + common + "common fishs, " + uncommon + "uncommon fishs, " + garbage + "garbage fishs")
        print("your coins are now:" + coins)
        begin()
    elif fish == "fish":
        print("You caught an uncommon fish!")
        uncommon = uncommon + 1
        coins = coins - 10
        print("You currently have, " + common + "common fishs, " + uncommon + "uncommon fishs, " + garbage + "garbage fishs")
        print("your coins are now:" + coins)
        begin()
    elif fish == "fish":
        print("You caught a garbage fish!")
        garbage = garbage + 1
        coins = coins - 10
        print("You currently have, " + common + "common fishs, " + uncommon + "uncommon fishs, " + garbage + "garbage fishs")
        print("your coins are now:" + coins)
        begin()
    if fish == "N":
        sell = input("Do you want to sell your fishs ? Y/N:")
        if sell == "Y":
            print("You currently have, " + common + "common fishs, " + uncommon + "uncommon fishs, " + garbage + "garbage fishs")
            print("You have sold your fishs.")
            coins = common * 12 + uncommon * 20 + garbage * 8
            common = 0
            uncommon = 0
            garbage = 0
            print("your coins are now:" + coins)


start()
I get an error with the print lines that print also variables, for example:
print("You currently have, " + common + "common fishs, " + uncommon + "uncommon fishs, " + garbage + "garbage fishs")
TypeError: Can't convert 'int' object to str implicitly
The variables you use in print are integers, while print can (at least directly) only take strings. So you need to convert them with str(), for example]:
str(common)
Reply


Messages In This Thread
why is it crushing ? - by Cheetos - Jan-26-2018, 01:29 PM
RE: why is it crushing ? - by j.crater - Jan-26-2018, 01:58 PM
RE: why is it crushing ? - by j.crater - Jan-26-2018, 02:14 PM
RE: why is it crushing ? - by Cheetos - Jan-26-2018, 02:17 PM
RE: why is it crushing ? - by j.crater - Jan-26-2018, 02:25 PM
RE: why is it crushing ? - by Cheetos - Jan-26-2018, 02:33 PM
RE: why is it crushing ? - by sparkz_alot - Jan-26-2018, 03:59 PM
RE: why is it crushing ? - by Cheetos - Jan-26-2018, 05:47 PM
RE: why is it crushing ? - by mepyyeti - Jan-26-2018, 06:17 PM
RE: why is it crushing ? - by league55 - Jan-26-2018, 05:34 PM
RE: why is it crushing ? - by DeaD_EyE - Jan-26-2018, 06:46 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020