[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/agdg/ - Amateur Game Development General

AGDG - The Board

Catalog

The next generation of Infinity is here (discussion) (contribute)
A message from @CodeMonkeyZ, 2ch lead developer: "How Hiroyuki Nishimura will sell 4chan data"
8chan ‘Press Conference’
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options
dicesidesmodifier
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, swf, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 5 per post.


Welcome to AGDG, have you ever made a game?
See also: /ideaguy/ | /vm/

File: 1443387617781.jpg (84.18 KB, 400x317, 400:317, 1437780545216.jpg)

3efab0 No.22413

I'm starting to get a little frustrated with CodeAcademy.

I'm jumping into their Python lessons because why the fuck not. Frequently, whenever I've completed a lesson I want to do some more playing with the code. Unfortunately there's no way to reset without moving on and returning to the lesson, which is annoying.

However, more frustrating is the fact that every time I want to play with my code, it's fucked up in some way. I don't feel like I've really learned anything outside of doing the prescribed steps involved in the particular lesson. Further, there's very limited resources to tell me exactly what I've done wrong.

Take this for example.

The lesson is to define a squaring function. Easy enough. However, the lesson is literally "Just call the function! Confused? The answer is squared(10) isn't programming accessable? :^)"

I said fuck that I want to be able to call this function on a user defined number.

def square(n):
"""Returns the square of a number."""
squared = n**2
print "%d squared is %d." % (n, squared)
return squared

# Call the square function on line 9! Make sure to
# include the number 10 between the parentheses.
number = raw_input("Gimmie a number, chump")
square(number)

How am I expected to know to use

int(raw_input("number is"))

since halfway through the course they have yet to explain the difference between strings and integers? Let alone how to input them?

3efab0 No.22414

File: 1443388273608.png (216.84 KB, 680x680, 1:1, 1422844351557.png)

Now this problem.

I went back to their "PygLatin" lesson. I wanted to be able to take the output which returns in all lowercase and modify it to make the final product have it's first letter uppercase. However, this code which worked to advance me forward in the lesson, no longer does so.

pyg = 'ay'

original = raw_input('Enter a word you hack')

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
new_word = word[1:len(new_word)] + first + pyg
print new_word
else:
print 'cmon son'

Returns

File "python", line 8, in <module>
NameError: name 'new_word' is not defined

I was playing it, trying to get to my goal. Any suggestions on how to do that? I asked in their Q&A forums and my question got deleted.


1ccf1e No.22418

File: 1443390766037.png (824 B, 120x160, 3:4, 031104.png)

>>22414

I don't know python but I think the problem is that you're trying to get length of new_word before it actually gets defined. Replace len(new_word) with len(word) or len(original) so the line will actually start making sense.


3efab0 No.22419

File: 1443392157691.png (25.75 KB, 600x800, 3:4, 1442904825003.png)

>>22418

Huh. I must have changed that at some point during my experiments and not even realized. Thanks.

And I got my experiment to work with a simple

print new_word.capitalize()

I'm retarded.




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]