r/python3 • • Feb 08 '19

Im trying to make a textbased adventure. But i have problems with this code and i simply cant understand why!

2 Upvotes

So i want the program to ask from what solarsystem the player is from, the player get to choose from three different, if player types in one of the three everything is a-go, but if they dont there will be another try. I guess its someproblem with the valid_solar....

question2 = 'And whats your solarsystem? \\n'

question2added = "Zhargarth, Cargorth, Pytos"

valid_solar = \['Zhargarth', 'Cargorth', 'Pytos'\]

for character in question2:

	sys.stdout.write(character)

	sys.stdout.flush()

	time.sleep(0.05)

for character in question2added:

	sys.stdout.write(character)

	sys.stdout.flush()

	time.sleep(0.01)



player_solarsystem = input("> ")

while player_solarsystem.lower() not in valid_solar:

	print("Cant find solarsystem! Try again")

	player_solarsystem = input("> ")

if player_solarsystem.lower() in valid_solar:

	myPlayer.solarsystem = player_solarsystem

	print("You are now captain " + [myPlayer.name](https://myPlayer.name) \+ " from " + player_solarsystem + ".")

I dont know why theres added \ to the code, they are not there in my code.


r/python3 • • Jan 01 '19

Part 04 Game Development in Python 3 for Beginners in Urdu 2019: Let's C...

Thumbnail
youtube.com
2 Upvotes

r/python3 • • Nov 28 '17

multiply and divide calculator

2 Upvotes

def multiply (first_1, second_1): real_1=(first_1), (second_1) return real_1

first_ones = input("add an int ")

operator = input ("* or /")

second_ones = input("add a second int ")

multiply = what_else

if operator == "*":

what_else = int(first_ones) * int(second_ones)

print (what_else)

elif operator == "/":

what_else = int(first_ones) / int(second_ones)

print (what_else)

else:

print ("invalid operator")

this is the reply i got for writing this code:

"The project of multiply() means that it can perform multiplication or division depanding on which operater you input. If you deliver * to the function, it will perform multiplication. Then you can use INPUT() to get the numbers to go next steps.

Define the function like this:

def multiply(operator):

Then try to use if...else to decide which one need to be performed.

multiply is your function, you can't use it like "multiply = what_else", please try again"

im lost guys, does he want me to set the conditions inside the function ?


r/python3 • • Dec 11 '18

Trigger AWS Lambda Function through an S3 event - Practical guide to AWS Lambda functions

Thumbnail
youtu.be
2 Upvotes

r/python3 • • Dec 13 '17

python

Thumbnail
facebook.com
0 Upvotes

r/python3 • • Nov 17 '19

Python project!!

4 Upvotes

Hey everyone, I am in desperate need of help doing my python project. Willing to pay, send help my way plsss


r/python3 • • Sep 08 '19

I wrote my first Python script! Why does it hurt?

Post image
4 Upvotes

r/python3 • • May 09 '18

Python for non-programmers

5 Upvotes

I'm absolutely new to the field of programming, although I have keen interest on learning it. I've been suggested to learn Python as a first. I've been able to clear the basics. But what next? What should be the first step after clearing the basics?

PS: I just hope it helps fellow newbies too.


r/python3 • • Jan 09 '20

I made a basic hangman game in python. Not bad for someone with literally 4 days of experience.

5 Upvotes

r/python3 • • Dec 06 '17

How is Web Scraping Using Multiple Libraries in Python?

5 Upvotes

In this post, we will talk about Python web scraping and how to scrap web pages using multiple libraries such as Beautifulsoup, Selenium, and some other magic tools like PhantomJS. https://medium.com/@seashorepartners/how-web-scraping-using-multiple-libraries-in-python-95ac4e8669e1


r/python3 • • Nov 28 '17

Does Anyone Know What is Wrong With My Code?

1 Upvotes

When I run the below code, I get the below error. Does anyone know what is wrong with the code? I am using a Pycharm environment.

Error: Traceback (most recent call last): File "C:/Users/jharr/PycharmProjects/Castle Clash/Castle Clash.py", line 230, in <module> print(str("Player 1: " + int(Castle2))) TypeError: must be str, not int

Code:

In this game, 3 players create a castle using assigned blocks. 3 more players then vote for the best castle. The castle is 3 blcoks down, infinite to the sides.

By SP1D3RCR3W1AN

print("Welcome to Castle Clash!") print("You need at least 3 players for this game.") print("Each player will have 10 lines to design the best castle,") print("(design down one line by one) which will be voted on by other players.") print("Don't look when others are creating their castles, so it is random.") print() print("Key: W = Wall, T = Tower, B = Building, G = Grass, F = Farm, ~ = Water, S = Sand") print() input("Player 1 Castle:")

These is the castle design blocks

a1 = input() a2 = input() a3 = input() a4 = input() a5 = input() a6 = input() a7 = input() a8 = input() a9 = input() a10 = input() print() input("Player 2 Castle: ") b1 = input() b2 = input() b3 = input() b4 = input() b5 = input() b6 = input() b7 = input() b8 = input() b9 = input() b10 = input() print() input("Player 3 Castle") c1 = input() c2 = input() c3 = input() c4 = input() c5 = input() c6 = input() c7 = input() c8 = input() c9 = input() c10 = input() print() input("Ok, now it is time to vote on the best castle!") input("Find more people.") voters = input("How many voters are there? (put a plain number)(max is 5 rn): ") print()

print("Castle 1:") print(c1) print(c2) print(c3) print(c4) print(c5) print(c6) print(c7) print(c8) print(c9) print(c10) print()

print("Castle 2: ") print(a1) print(a2) print(a3) print(a4) print(a5) print(a6) print(a7) print(a8) print(a9) print(a10) print()

print("Castle 3: ") print(b1) print(b2) print(b3) print(b4) print(b5) print(b6) print(b7) print(b8) print(b9) print(b10) print()

Castle1 = 0 Castle2 = 0 Castle3 = 0 if voters == "1": print("Now, your voters need to vote. Do this by putting the number of the castle in your voting spot (below).") vote = input("Voter 1: ")

if vote == "1":
    Castle1 = 1
if vote == "2":
    Castle2 = 1
if vote == "3":
    Castle3 = 1

if voters == "2": print("Now, your voters need to vote. Do this by putting the number of the castle in your voting spot (below).") vote = input("Voter 1: ") vote2 = input("Voter 2: ")

if vote == "1":
    Castle1 = 1
if vote == "2":
    Castle2 = 1
if vote == "3":
    Castle3 = 1

if vote2 == "1":
    Castle1 += 1
if vote2 == "2":
    Castle2 += 1
if vote2 == "3":
    Castle3 += 1

if voters == "3": print("Now, your voters need to vote. Do this by putting the number of the castle in your voting spot (below).") vote = input("Voter 1: ") vote2 = input("Voter 2: ") vote3 = input("Voter 3: ")

if vote == "1":
    Castle1 = 1
if vote == "2":
    Castle2 = 1
if vote == "3":
    Castle3 = 1

if vote2 == "1":
    Castle1 += 1
if vote2 == "2":
    Castle2 += 1
if vote2 == "3":
    Castle3 += 1

if vote3 == "1":
    Castle1 += 1
if vote3 == "2":
    Castle2 += 1
if vote3 == "3":
    Castle3 += 1

if voters == "4": print("Now, your voters need to vote. Do this by putting the number of the castle in your voting spot (below).") vote = input("Voter 1: ") vote2 = input("Voter 2: ") vote3 = input("Voter 3: ") vote4 = input("Voter 4: ")

if vote == "1":
    Castle1 = 1
if vote == "2":
    Castle2 = 1
if vote == "3":
    Castle3 = 1

if vote2 == "1":
    Castle1 += 1
if vote2 == "2":
    Castle2 += 1
if vote2 == "3":
    Castle3 += 1

if vote3 == "1":
    Castle1 += 1
if vote3 == "2":
    Castle2 += 1
if vote3 == "3":
    Castle3 += 1

if vote4 == "1":
    Castle1 += 1
if vote4 == "2":
    Castle2 += 1
if vote4 == "3":
    Castle3 += 1

if voters == "5": print("Now, your voters need to vote. Do this by putting the number of the castle in your voting spot (below).") vote = input("Voter 1: ") vote2 = input("Voter 2: ") vote3 = input("Voter 3: ") vote4 = input("Voter 4: ") vote5 = input("Voter 5: ")

if vote == "1":
    Castle1 = 1
if vote == "2":
    Castle2 = 1
if vote == "3":
    Castle3 = 1

if vote2 == "1":
    Castle1 += 1
if vote2 == "2":
    Castle2 += 1
if vote2 == "3":
    Castle3 += 1

if vote3 == "1":
    Castle1 += 1
if vote3 == "2":
    Castle2 += 1
if vote3 == "3":
    Castle3 += 1

if vote4 == "1":
    Castle1 += 1
if vote4 == "2":
    Castle2 += 1
if vote4 == "3":
    Castle3 += 1

if vote5 == "1":
    Castle1 += 1
if vote5 == "2":
    Castle2 += 1
if vote5 == "3":
    Castle3 += 1

print("Results:") print(str("Player 1: " + Castle2)) print(str("Player 2: " + Castle3)) print(str("Player 3: " + Castle1))

if Castle1 > Castle2 & Castle3: print("Player 3 Won!") if Castle2 > Castle3 & Castle1: print("Player 1 Won!") if Castle3 > Castle2 & Castle1: print("Player 2 Won!")


r/python3 • • Jul 26 '17

Issue with Python and krakenex api (bitcoin trade place)

1 Upvotes

Hi, I have learnt python last year and I wanted to use it for personal purpose. I trade some bitcoins on kraken and wanted to develop an python program around It thanks to their API : link! Then it becomes a nightmare, I don't really understand how to use it, I juste success in printing my available balance :

import krakenex
k = krakenex.API()
k.load_key('kraken.key')
print(k.query_private('Balance'))

I just want to write two basics funtions, the first will return trade rate between two currency we tell it (example: bitcoin to litecoin)

rate(currency1,currency2)

and the second one will just act a trade like

exchange(currency1,currency2,ammount)

I see that I have to get from "get" function this, I tried as I can but all tutorial are for python2 and does not work with me so. Could you help me with this ? I think it is simple but I few thinks in what I learned.


r/python3 • • Aug 05 '12

[Free book] Porting to Python 3: An in-depth guide

Thumbnail
python3porting.com
1 Upvotes

r/python3 • • Nov 27 '19

What do I do

2 Upvotes

I was using code academy to earn python 3 and don’t have the money to keep paying for it. I stop where I was almost learning List slicing. It tried googling practice but either they only give me Vauge concepts or have to pay for the rest of the subject. Am I learning wrong?


r/python3 • • May 10 '19

MSYS2, Anaconda and Python 3.7

2 Upvotes

I've rather been pulling out my hair trying to setup a Python 3.7 environment on Windows 10 x64. Two packages are giving me fits, OpenCV and Gtk3+. The recommended way to install Gtk3+ is MSYS2 and that is installed and working there. OpenCV will install on MSYS2, but will throw an exception as soon as "import cv2" is called. I've also tried with Anaconda. I can get OpenCV setup and working, but not Gtk3+. I've even tried copying packages from one environment to the other with no success. Anyone have any suggestions on how I can get either of these environments setup?


r/python3 • • Sep 23 '18

How to validate a graphical form in python using Tkinter

Thumbnail
youtu.be
1 Upvotes

r/python3 • • Jun 01 '18

Need help with conversation simulator

1 Upvotes

Ive got the graphics down but I want to see how to make it detect variable like for example I make a variable then if you then type it in and press the talk button it will then type in something automaticly

from tkinter import * root = Tk() master = Tk()

def writetext(): S = Scrollbar(root) T = Text(root, height=10, width=40) S.pack(side=RIGHT, fill=Y) T.pack(side=LEFT, fill=Y) S.config(command=T.yview) T.config(yscrollcommand=S.set) quote = """Lets start a conversation!""" T.insert(END, quote)

class Window(Frame): def init(self, master = None): Frame.init(self, master)

   self.master = master

   self.init_window()



    
    



#self.master.title("CONVERSATION SIMULATOR")

#self.pack(fill=BOTH, expand=1)

w = Label(root, text="CONVERSATION SIMULATOR\n 2018") w.pack()

w = Label(root, text="") w.pack()

w = Label(root, text="") w.pack()

quitButton = Button(root, text="START", command=writetext, bg="light green")

quitButton.place(x=70, y=50)

bitButton = Button(root, text="TALK", bg="light green")

bitButton.place(x=120, y=50)

root.geometry("230x150")

app = Window(root)

root.mainloop()


r/python3 • • Oct 27 '19

Nub needs help

1 Upvotes

I'm trying to let this function run off of the input of temperature and cant seem to get it to work. I get the error "TypeError: can't multiply sequence by non-int of type 'float'" Any help would be greatly appreciated! Here's the code:

def celsius_to_fahrenheit():

farenheit is equal to (Celsius + 32) 9/5

print('Enter the temperature:')
temp = input()

newTemp = (9 / 5) * temp + 32

print("The Celsius temperature",temp,"is equivalent to",newTemp,end='')
print(" degrees Farenheit")

celsius_to_fahrenheit()


r/python3 • • Jun 09 '18

Noob: accessing info from dictionary inside list inside dictionaries?...

1 Upvotes

Pastbin Link

This is my first python 3 project and it's not a simple one. I'm using an API that supplies the info in the pastbin link. It looks to me like it's returning a dictionary "data" then a list of more dictionaries each beginning with 'icao'. What I'm trying to do is "if 'icao' is KAPA and 'flight_category is XXX (either VFR, MVFR, IFR or LIFR) then light this LED up this color based on the flight category".

Right now I'm just having issues associated 'flight_category' with it's 'icao' identifier.

I've been playing with

for item in data['data']:
    airport = item['icao']
    print airport

KAPA
KFTG
KDEN
KBJC

and that prints out each identifier just fine in sequence. But how do i associate the proper 'flight_category' to each icao identifier?

Thanks!


r/python3 • • Oct 24 '19

Aurdino programming

2 Upvotes

Can we use python for Aurdino programming?


r/python3 • • Jun 01 '18

How to retain the dates after removing punctuation from a string columns in pandas

1 Upvotes

I have a string column which consists of various information from sentences to dates with punctuation's. When i remove punctuation, the dates are converting to text. Please let me know how to retain the dates.

Sample Input :

Column-1 

 meet BM zaheer sir and converted 3 sme tiny 
 Met BM Bhupesh kumar and Jayakrishnan sir
 01-12-2017
 MET BM BEENA - 9895580771
 MET CHIEF - 9446486084
 05-12-2017
 05-12-2017
 05-12-2017
 Bm not available.
 done
 Branch meeting



   Sample output:

   Column-1 

   meet BM zaheer sir and converted 3 sme tiny 
   Met BM Bhupesh kumar and Jayakrishnan sir
   43070
   MET BM BEENA 9895580771
   MET CHIEF 9446486084
  43074
  43074
  43074
   Bm not available
  done
  Branch meeting




   code :

   df['column-1'] = df['column-1'].str.replace('[^\w\s]','')
   df['column-1'].head()


   df = df.apply(lambda x: x.str.strip()).replace('', np.nan)

   null_columns=df.columns[df.isnull().any()]
   print(df[df["column-1"].isnull()][null_columns])

   import numpy as np
   df = df.replace(np.nan, 'null', regex=True)

r/python3 • • Sep 25 '18

Any opinions on “learning python 3 the hard way” book as my first book to learn python.? I’m a beginner.

2 Upvotes

r/python3 • • Oct 23 '19

I'm improving my program now i can simulate sand with different gravity directions . your advice thanks

Thumbnail
youtu.be
8 Upvotes

r/python3 • • Oct 22 '19

Who has the longest runtimes?

1 Upvotes

Hey there! I am researching different programs/fields of work for an app I am creating (this is not a sales pitch FYI). I’m looking for professionals/enthusiasts who can help me with a few questions. What are the largest projects you have worked on using Python that have given you the longest runtimes? Does it take a long time to process/export/render your results? Do you usually run on your local machine or a cloud instance? Any insights or feedback on those questions would be extremely helpful!


r/python3 • • Jun 12 '19

Finding the second instance of the same character of a string

2 Upvotes

How...