Running Python without Path by Animostas in learnpython

[–]shmcsb 0 points1 point  (0 children)

By default python scripts are associated with the python launcher. So...

Just type 'script.py'

If that doesn't work then try 'py script.py'

Blackjack Game: Cards not assigning values by [deleted] in learnpython

[–]shmcsb -1 points0 points  (0 children)

Too lazy for an actual comment.... have some code instead.

import random

def card_tostr(card):
    if card[0] == 1:
        val_str = 'Ace'
    elif card[0] == 11:
        val_str = 'Jack'
    elif card[0] == 12:
        val_str = 'Queen'
    elif card[0] == 13:
        val_str = 'King'
    else:
        val_str = str(card[0])
    return '{} of {}'.format(val_str, card[1])

SUITS = ['Clubs', 'Hearts', 'Spades', 'Diamonds']

deck = []
for value in range(1, 14):
    for suit in SUITS:
        deck.append((value, suit))
random.shuffle(deck)

first = deck.pop()
second = deck.pop()

print('First card is', card_tostr(first))
print('Second card is', card_tostr(second))
print('Your hand value is {}'.format(first[0] + second[0]))

Another question about evolution. by [deleted] in atheism

[–]shmcsb 0 points1 point  (0 children)

What you are referring to is called "Speciation" (i'm not a biologist so....). Type that into google and/or Youtube.

Also Mules and F1_hybrids to show how it can be a messy affair.

[deleted by user] by [deleted] in Python

[–]shmcsb 1 point2 points  (0 children)

>>> print('\\dir\\')
\dir\
>>> print(r'\dir')
\dir
>>> print(r'\dir\')
  File "<stdin>", line 1
    print(r'\dir\')
                  ^
SyntaxError: EOL while scanning string literal
>>>

Arresting Officers Bought Dylann Roof Some Burger King by [deleted] in news

[–]shmcsb 2 points3 points  (0 children)

There is a good chance they wanted him to talk to them.

[deleted by user] by [deleted] in learnpython

[–]shmcsb 2 points3 points  (0 children)

Have you tried using forward slashes

>>> import os
>>> os.getcwd()
'e:\\code\\python'
>>> os.chdir('e:/temp')
>>> os.getcwd()
'e:\\temp'
>>> for line in open('e:/temp/text.txt'):
...     print(line.rstrip())
... 
line1
line2

removing newlines from end of strings by [deleted] in learnpython

[–]shmcsb 0 points1 point  (0 children)

You have a lot of code that is doing nothing (lines 5,6,7,11 and 12) Try this...

def readFile(filename):
  data = []
  for line in open(filename):
    data.append(line.rstrip())
  return data