Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

3 Neutral

About Truman

  • Rank
  • Birthday 06/12/1986

Contact Methods

  • Skype
    milos bogdanovic 735

Profile Information

  • Location
    Belgrade, Serbia
  1. Problem with random

    If anyone wants to know I had to install python again with pip, now it works fine.
  2. Problem with random

    I intend to make lottery drawing program but first wanted to check the basic random module with a code: from random import * print(randint(1, 100)) Instead I receive a comment from cmd that contains output of some other file that I created None of my files is named random.py. I have no idea how is this possible.
  3. Break statement code

    Interesting note, will keep that in my mind. Error message points to line 5 - break.
  4. Break statement code

    Actually, else is lined up with for in official python tutorial and when I change it to what you suggested nothing changes...
  5. Break statement code

    This is how my code actually looks like in notepad++. From some reason forum <> function doesn't paste code with the same indentation. Regarding the understanding of the code I understand mod operator but my miscomprehension was due to relation between for and else. Mixed things, now it's clearer.
  6. For statement with slice copy

    words = ['book', 'superficial', 'nostradamus'] for w in words: print(w, len(w)) for w in words[:]: if len(w) > 6: words.insert(0, w) words ['defenestrate', 'cat', 'window', 'defenestrate'] this is my code.
  7. Break statement code

    for n in range(2, 10): for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n//x) break else: print(n, 'is a prime number') There are two issues here: 1. TabError: Incosistent use of tabs and spaces in indentation 2. More importantly I don't understand the logic behind this code that leads to this output:
  8. For statement with slice copy

    You're correct but after changing it to square brackets I receive TypeError: list indices must be integer or slices, not tuple.
  9. For statement with slice copy

    It looks so, you can find it here: https://docs.python.org/3.6/tutorial/controlflow.html 4.2. for Statements
  10. For statement with slice copy

    Hi, I'm looking at this piece of code: words = ['cat', 'window', 'defenestrate'] for w in words[:]: if len(w) > 6: words.insert(0, w) words ['defenestrate', 'cat', 'window', 'defenestrate'] If I understand well it should make copy of the list and add 'defenestrate' into list but I receive a message "tuple object has no attribute instert". This code is a part of a tutorial I'm following and not sure why it doesn't work.
  11. Why this code doesn't run?

    Thanks, I closed php code before <!DOCTYPE...>' and now it works...
  12. Why this code doesn't run?

    How could I know that the error is on line 3 of another file? And this is the code for header.html: <?php // Script 1.4 - header.html include('functions.php'); <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" media="all" href="css/style.css" /> <title><?php if (defined('TITLE')) { print TITLE; } else { print 'My site of quotes.'; } ?></title> </head> <body> <div id="container"> <h1>My site of quotes.</h1> <br /> <! -- Begin changeable content. -->
  13. Why this code doesn't run?

    I wrote a simple code for logout: <?php // Script 1.7 - logout.php if (isset($_COOKIE['Samuel'])) { setcookie('Samuel', FALSE, time()-300); } define('TITLE', 'Logout'); include('templates/header.html'); print '<p>You are now logged out.</p>'; include('templates/footer.html'); ?> but I receive: Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\my-site\all\templates\header.html on line 3 This makes no sense to me...
  14. Handling file uploads

    Actually this '$FILES' was a mistake, when I corrected it worked! I already made uploads directory for this purpose. I will also take a look on other suggestions that you and your colleagues gave me on this topic.
  15. Handling file uploads

    After adding error 7 and error 8 I still receive the default error message.