Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Ceaser cipher program
Post: RE: Ceaser cipher program

Take a look at what your code does each step. First, you assign the value 1 to shift. Then, each iteration of the loop, you add the value of shift to the next letter. So the first letter has 1 adde...
TomToad Homework 5 2,849 Sep-10-2020, 11:09 AM
    Thread: how to encode and decode same value
Post: RE: how to encode and decode same value

Might be better to first encode random data, then decode the result to see if you get the original data, instead of the other way around. base64 encrypted data will always be printable ASCII characte...
TomToad General Coding Help 2 2,328 Sep-08-2020, 09:46 AM
    Thread: Iterating over word vs. character
Post: RE: Iterating over word vs. character

You can use the join() method to join all the strings into one.
TomToad General Coding Help 6 2,565 Aug-11-2020, 12:23 PM
    Thread: Whats the difference between these two?
Post: RE: Whats the difference between these two?

Try calling each function with this code and note the difference in output. an you figure out why it is different? for speed in range(50,100,20): print(f'speed = {speed} : {caught_speeding(speed, Fa...
TomToad Homework 4 3,394 Jul-08-2020, 11:10 AM
    Thread: Why is the item not in list when it is
Post: RE: Why is the item not in list when it is

You need to put your code between python tags when posting. Also, when you pick the new card, you try to remove it from the deck twice.
TomToad General Coding Help 2 2,026 Jul-08-2020, 10:50 AM
    Thread: Help! Function doesn't run
Post: RE: Help! Function doesn't run

The function actually does run, but it gets stuck in a nearly endless loop. That is because you reset primes to an empty list in each iteration.
TomToad General Coding Help 5 2,474 Jul-07-2020, 11:24 AM
    Thread: why in Python some time "n += 1" not like "n = n + 1" ?
Post: RE: why in Python some time "n += 1" not like "n =...

In proc2(), a new object n is created that is local to proc2() and then lost when the function is exited. In order to keep the result, you need to return it. list1 = [1, 2, 3] list2 = [1, 2, 3] def...
TomToad General Coding Help 4 1,946 Jul-06-2020, 11:46 AM
    Thread: Lunar Lander Text Game
Post: RE: Lunar Lander Text Game

Nice. took 3 tries to not crash. Reminds me of this BASIC game from 1979.
TomToad Code sharing 1 3,129 May-17-2020, 12:21 AM
    Thread: Help with Code
Post: RE: Help with Code

The part that calculates the area works just fine; however, there is an error in line 9 that keeps the code from running. Obviously, you modified the code for posting and removed the original error w...
TomToad General Coding Help 1 1,831 May-16-2020, 05:47 PM
    Thread: Irrational number
Post: RE: Irrational number

There is no way to consistently determine if a number is irrational for a couple of reasons. First, in mathematics, there is no single proof that can be used on all irrational numbers. Some number...
TomToad General Coding Help 11 7,034 May-08-2020, 06:23 PM
    Thread: Python logical operator AND
Post: RE: Python logical operator AND

To get the result that you are expecting, you would use bitwise operators. a = 6 b = 7 print(a & b) #& is bitwise and
TomToad General Coding Help 4 2,518 May-07-2020, 01:52 PM
    Thread: Coordinates from a text file
Post: RE: Coordinates from a text file

text = '''******F**** *****W*****''' print ("text =",text) ls = text.splitlines() print ("ls =",ls) ls2 = [[letter for letter in line] for line in ls] print ("ls2 =",ls2)
TomToad General Coding Help 7 4,802 May-04-2020, 12:46 PM
    Thread: Reason of the output
Post: RE: Reason of the output

It is because you only iterate over the first value, then return when x = 6. If you want it to iterate over all the values, then you need to stay in the loop until a match is found. def fun(a,k): ...
TomToad General Coding Help 2 2,173 Apr-28-2020, 10:44 AM
    Thread: Python Consecutive characters
Post: RE: Python Consecutive characters

You can do this with regular expressions import re regex = re.compile(r'((.)\2*)') matches = regex.finditer("aaaabbbccddddddddeee") s = "" for match in matches: if len(match.group(0)) > 3: ...
TomToad General Coding Help 4 4,963 Apr-22-2020, 11:03 AM
    Thread: string indices must be integers
Post: RE: string indices must be integers

data is the dictionary. When you do for element in data, element takes on the value of the key, first iteration, it is 'sentence', second iteration, it is 'tags' Get rid of the for loop and it will ...
TomToad General Coding Help 6 3,710 Apr-22-2020, 10:13 AM
    Thread: printing a ✔
Post: RE: printing a ✔

It has to do with the font that the console is set to. When I use MS Gothic, I get the check mark. PowerShell has even more fonts that can display the check mark. I also found that if you used a '✓'...
TomToad General Coding Help 12 10,293 Apr-17-2020, 01:16 PM
    Thread: A Dictionary in a Dictionary Syntax
Post: RE: A Dictionary in a Dictionary Syntax

Problem is that you have strings within a string. Python can't tell where one begins and the other one ends. you have three ways to fix this. 1. change the outer string from double quotes to singl...
TomToad General Coding Help 3 2,145 Apr-16-2020, 07:16 AM
    Thread: angle of rotation
Post: RE: angle of rotation

add if angle_radian < 0: angle_radian += math.tauafter the angle_radian = ... in line 28
TomToad Game Development 4 2,990 Apr-15-2020, 06:56 PM
    Thread: Error "Else expected"
Post: RE: Error "Else expected"

Often times, where the error is detected isn't on the line where the error occurs. Look carefully at the previous lines and see if there is an error. hint: count the parentheses
TomToad Game Development 1 5,477 Apr-15-2020, 10:15 AM
    Thread: NOI 2013 Q1
Post: RE: NOI 2013 Q1

It looks like you are trying to go over all possible sea levels, figuring out which sea level creates the highest number of islands, then returning the number of islands at the maximum. Am I right? ...
TomToad Homework 10 3,837 Apr-14-2020, 03:01 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020