#πŸ”’ RPG Character Builder - capitalization

89 messages Β· Page 1 of 1 (latest)

tardy chasmBOT
#

@velvet prairie

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

plush meadow
#

!e

print("SoMe wEird String".capitalize())```
tardy chasmBOT
#

@plush meadow :white_check_mark: Your 3.12 eval job has completed with return code 0.

Some weird string
barren pasture
#

!e

print('lMaO lOoooL'.title())
tardy chasmBOT
#

@barren pasture :white_check_mark: Your 3.12 eval job has completed with return code 0.

Lmao Looool
velvet prairie
#

these are allowing me to output the properly capitalized thing, but my list has all lower case entries that it checks inputs against for match .. currently, it loops if you input 'Human' where 'human' is expected

#

sorry .. i know im saying all of this wrong

warm grotto
#

!d str.casefold

tardy chasmBOT
#

str.casefold()```
Return a casefolded copy of the string. Casefolded strings may be used for caseless matching.

Casefolding is similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string. For example, the German lowercase letter `'ß'` is equivalent to `"ss"`. Since it is already lowercase, [`lower()`](https://docs.python.org/3/library/stdtypes.html#str.lower) would do nothing to `'ß'`; [`casefold()`](https://docs.python.org/3/library/stdtypes.html#str.casefold) converts it to `"ss"`.

The casefolding algorithm is [described in section 3.13 β€˜Default Case Folding’ of the Unicode Standard](https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf).

Added in version 3.3.
barren pasture
#

how do i make sure these links are safe?

warm grotto
#

The pythondiscord pastebin links?

barren pasture
#

yeah

warm grotto
#

!paste

tardy chasmBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

warm grotto
#

^

barren pasture
#

i see

#

i've opened into some scary looking ones

warm grotto
#

You can ask in #python-discussion maybe

#

Oh it's just a pastebin

#

some people paste some ratchet stuff though

#

As long as you don't download it and run it you're fine

barren pasture
#

apologies for the side track

velvet prairie
#

just back, reading

#

how can i end a running program in vscode?

#

its wrongly looped somehow and wont let me out lol

#

nm i got it

velvet prairie
#

im getting a infinite loop somehow now

#

!paste

tardy chasmBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

barren pasture
#

paste it again its empty

velvet prairie
#

getting into hard to parse territory for me :P

barren pasture
#

where are you getting the inf loop?

velvet prairie
#

All that I require from you is a yes or no answer.

#

that print

#

i have to ctrl+c to interrupt it

#

its calling out line 102 and 34 but idk why

#

it only breaks if i input something other than yes_ or no_answers

#

sorry that was probably helpful 5min ago

#

like when it asks "will you allow fate ... ?" if you answer "hippo" it infiniteloops that print

barren pasture
#

add a 'break' below print('All that I require from you is a yes or no answer.')

velvet prairie
#

but then it moves on

#

i do want it to loop back to the FATE question

barren pasture
#

my bad, try 'continue' instead of break

#

i probably gotta run ur code

velvet prairie
#

that still loops

#

i, michael, swear on everything holy, that my code is pure and true

#

lmao

#

i wouldnt be able to send you spicy code if i tried rn

barren pasture
#

think i got it

#

hahahah no worries i looked at your code there's nothing wrong

#

i mean

#

in terms of... bad code

#

i got the solution i think

#

i moved the sex_test input into the while True loop in the fate_sex function

#

the else loop for "all i require..." is moved one indent to the left, in line with "if sex_test in answers" (line 17), just in case u didn't notice

#

@velvet prairie lmk it works for u

velvet prairie
#

it did

#

there was another bug

#

i got it

#

it all works now

barren pasture
#

πŸ‘

velvet prairie
barren pasture
#

you could do something along the lines of

#

get the index of the effective_race using races.index(), then pass in that index into pt and bt

#

and then return trait1 and 2

#

this is with assumption your order of elements in races is always consistent with the order in pt and bt

#

!e

races = [ 'dwarvan', 'elvan', 'gnoman', 'goblan',
          'halvan', 'human', 'northman', 'orcan']

pt = ['a beard', 'pointed ears', 'a bald head', 'greenish skin', 'hairy feet', 'an unremarkable appearance', 'blonde hair', 'lower tusks']
bt = ['stonewise', 'swift of though & action', 'a tinker', 'cunning', 'silent', 'talented', 'quick to rage', 'intimidating']

effective_race = 'elvan'
effective_race_idx = races.index(effective_race)

trait1, trait2 = pt[effective_race_idx], bt[effective_race_idx]

print(trait1, ", ", trait2)
tardy chasmBOT
#

@barren pasture :white_check_mark: Your 3.12 eval job has completed with return code 0.

pointed ears ,  swift of though & action
velvet prairie
#

not working as is

#

not sure what i did wrong

#

oh i got it

#

since i used capitalize

#

i had to capitalize the races

velvet prairie
#

right now, both recessive traits are displayed

#

i would like it so that each recessive trait has a 25% chance of occurring

#

i had this coded in another thing, but it looks totally different now, and i dont know how to go about thinking about how to do it

#

like i want to do a if statement in the middle of the format displays, but idk if i can or how

#

there is probably a better way

tardy chasmBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

πŸ”’ RPG Character Builder - capitalization