brogen
@brogen
Channel your inner porpoise.
I am working on a text adventure and when I put in one number all of the things that would happen when it is put in are called at once. (ļ¼'ā') Will yo
RYANTADIPARTHI You have too many if statements. Try elifs too. And indent everything. IT seems you are not indenting everything properly.3 years ago
I want to try to play a sound but I don't know how.
I want to make a eating contest you can enter in and I need to know how to do chance statements.
š·šš½
Pigs are the best!
You can play the game now
Python
DynamicSquid You can use a random number generator for that
import random
num = random() # generate random decimal between 0 and 1
if num < 0.5:
do something
else:
do something
`3 years ago
This is a game where you would train up dogs and sell them. However after you train once you can't train again. Please help me find out why.
Python
Bookie0 Hi,
I think the reason why is because you're asking if they want to train or sell in the if loop with the training. A code where you can always train your dog would look a bit like this:, using functions:
def train(): # defining the train function
print("Rolling over")
print("playing with toy")
etc.
put all the other code for the training here
while True: # infinity loop to always go on and on
menu = input("What do you want to do? train - 50 or sell?")
if menu == "train" and money 3 years ago
Coder100 ok, on line 40, why do you have two arguments when it takes 0?
habachi.describerestaurant(name, dishtype)
Correct code
habachi.describe_restaurant()
ig you overthought it lol3 years ago
I want to be able to do something every set amount of time. like every second get one dollar from your buisiness.
Python
Coder100 sure, try something like this:
import time
while True:
print("Time is ten seconds.")
time.sleep(10)
Do note that means any code after it won't get executed
import time
while True:
print("Time is ten seconds.")
time.sleep(10)
print("I never happen")
`3 years ago
I want to try and use the data base for a project to have a password set up and you can input the password and that password is asighned to you foreve
Python
Coder100 Try something like:
from replit import db
input('sign up? (y/n): ')
if signup == 'y':
username = input('username: ')
password = input('password: ')
db[username] = password
else:
username = input('username: ')
password = input('password: ')
if (db[username] == password):
print('welcome %s!' % username)
`3 years ago
happy holidays! If you like christmas upvote also you can comment down below and talk
Python
it might not be to exilerating but t it's my first project. you may change the symbols in the printing to make different patterns.
Python
i want to be able to print patters on something typed in. help! please.
Python
PattanAhmed @brogen Hi,
Can you please explain a little bit more for our Clarification!
Thanks!3 years ago
i need to go slowly instead of putting the whole thing on at once.
Python
PattanAhmed @brogen Hi,
Here is the code you can try:-
It will print Letter-by-Letter
import time,sys
def typewriter(message):
for i in message:
sys.stdout.write(i)
sys.stdout.flush()
if ((i != "\n") and (i != ":")):
time.sleep(0.09)
else:
time.sleep(0.6)
text = 'Letter-by-letter'
typewriter(text)
Thanks!
Hope this helps3 years ago
Coder100 Hi! Try this:
import time
def typewriter(text, delay=0.1):
for letter in text:
print(letter, end='', flush=True)
time.sleep(delay)
print()
typewriter("I'm being typed at a rate of 0.1 seconds")
typewriter("I'm being typed at a rate of 0.05 seconds", 0.05)
`3 years ago
PattanAhmed @brogen Hi,
Use something called While Loop:-
Code:-
while True:
print('This will print infinite times')
Thanks!
Hope this helps3 years ago
brogen can you tell me how to print slowly like typing instead of printing the whole thing really fast3 years ago
Coder100 You can use a while loop for that:
while True:
print("hi!")
read more here
Also, btw use break to end the loop3 years ago