You need to call the function "input"
So it'd look like:
input()
You need to call the function "input"
So it'd look like:
input()
The escape character "\t" for tabs works wonders ;)
Well, since there was no option for "tutorial" in the type of post, it has been created as a simple thread...
Obfuscation - confusion resulting from failure to understand
obfuscated code - Code that is hard to read
In this tutorial, I will show you how to convert something readable, to something completely unreadable, but it still works, exactly the same. There are multiple thing you can do in Python to achieve obfuscation, one of the main ones being one-liners and exec(). I have not understood the lambda function yet, but you can still pull off loops and if statements that have one statement, by putting them on the same line; I.e.:
x = 1
# This:
if x == 1:
print("x is equal to 1")
# Becomes this:
if x == 1: print("x is equal to 1")
Both work exactly the same.
Next, we shall take a look at a string:
toexec = '''x = 0
if x == 0:
print("Hello world")
'''
You might be asking, well, what does this have to do with anything? Here's the answer, the exec()
can execute this string as actual code. If you type in toexec
in the interpreter, you're shown this: 'x = 0\nif x == 0:\n print("Hello world")\n'
Now, if you type this: exec(toexec)
You are now presented with this: 'Hello world'
Nifty, eh? Another way of obfuscating your code is through use of ord() and chr(). That toexec code can also be represented …
Okay, sorry. The tuple appears to not have a .split() function, only a list does. So, we shall go ahead and convert the tuple to a list, then iterate through the split:
n = []
for x in events:
n.append(x)
# Make the tuple to a list
events = n[:]
# NOTE:
# You could just do a conversion using the list() function;
# IE. events = list(events)
# Less typing, but the other way you'll understand how the tuple and list works
# Separate the events at the '\n' marker
for x in events[0].split('\n'):
# Iterate through the list of each entry
for y in x:
# print the result
print y
num = int(raw_input("Enter a Number: "))
for x in range(0, num):
raw_input()
That should provide a basis for your loop
Also, do not assign variables to built-in functions, such as 'list'. It's a bad idea to do
@ Sahiti:
Please learn netiquette and some english, not "eubonics", or "txtspeak" on online forums. While we will help you, we would like if you spoke as you would in a normal conversation. Also, if you need help with the 'C' syntax/language, please ask in the appropriate forum.
Thank you :D
This code should be able to get you started to design 2-D scrolling games, like Mario. I spent a few hours trying to figure this out, and firgured I'd put up my efforts. I think there might be a better way to do it, but this should help you get started.
This is understandable. My girlfriend loves to have sexual RP's with a lot of people online. It doesn't bother me at all. I'm not good at it for her, and it's not like I should control what she does online where it doesn't matter. :/ It's stupid to take it so seriously
:D I never knew about that module! I only knew about the math module... anyways, I like my method better, more work and thinking involved xD
Never mind the fact that I love math.
Hey no problem. I've been coding for the past month, python is my first language. It took me a while to learn that. :D
When you call it, are you just typing what it's called, or are you typing name(), and adding in any arguements? Note that even if your function or class does not require any arguements, when it's defined, you still need to add () after it, and when called, it should be as name(). Hope this helps :D
This is what I would do. Create a loop for generating the numbers, and inside that loop, if the number is 1-10, then a = a + 1, 2-20, then b = b+ 1, etc., until you reach the end. Such as this [Note it's untested, this is just at template to get your brain working]:
import random
x = 0
while x < (the number you want):
rannum = random.randint(a, b) Where a and b are the numbers you define
if rannum <= 10 and rannum >= 1:
a = a + 1
if rannum < 20 and rannum > 11:
b = b + 1
print "The number of times a number was generated between 1 and 10 was: %d" %(a)
print "The number of times a number was generated between 11 and 20 was: %d" %(b)
Note that I'm not sure that %d is the one you use for integers. Hope this helps! :D