wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
let y: number | null = null; y.toFixed(99); | let y: number | null = null; if(y!==null) y.toFixed(99); | Null check. | TypeScript |
function process(): void {{ return 61; }} | function process(): number {{ return 61; }} | Return type mismatch. | TypeScript |
for (z in arr) | for (z of arr) | for...in iterates keys. | JavaScript |
function test(data)
print(data)
end | function test(data)
print(data)
end | Correct. | Lua |
jwt.sign({{id:55}}, 'key'); | jwt.sign({{id:55}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
print('world') | print('world') | Correct. | R |
for i=1,20 do print(i) end | for i=1,20 do print(i) end | Correct. | Lua |
let count = 89; count += 1; | let mut count = 89; count += 1; | Need mut to modify. | Rust |
JOIN orders ON products.id = orders.id | JOIN orders ON products.id = orders.id | Correct. | SQL |
def baz(a):
return a + 1 | def baz(a):
return a + 1 | Correct. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
if [ $z = 45 ]; then | if [ "$z" = 45 ]; then | Quote variable. | Shell |
if (b = 47) {{}} | if (b == 47) {{}} | Use ==. | Kotlin |
List(83,86,31) | List(83,86,31) | Correct. | Scala |
'test' + 19 | 'test' + str(19) | Can't add int to string. | Python |
a > 63 & x < 17 | a > 63 and x < 17 | Use 'and' not '&'. | Python |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<person age=9> | <person age="9"> | Quote attribute. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
h1 {{ font-size:33px color:green; }} | h1 {{ font-size:33px; color:green; }} | Add semicolon. | CSS |
$list[99] | if ($list.Count -gt 99) {{ $list[99] }} | Check bounds. | PowerShell |
let b: Int = 'result' | let b: String = 'result' | Fix type. | Swift |
<br></br> | <br> | Self-closing. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(87); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(87, () => console.log('listening')); | Add callback. | Node.js |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
var x int | var x int | Correct. | Go |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
y > 90 & z < 55 | y > 90 and z < 55 | Use 'and' not '&'. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if count > 96
print('data') | if count > 96:
print('data') | Colon missing after if. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
if ($b = 67) | if ($b == 67) | Use ==. | Perl |
WHERE age = '59' | WHERE age = 59 | Don't quote integer. | SQL |
function test(): void {{ return 68; }} | function test(): number {{ return 68; }} | Return type mismatch. | TypeScript |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
render | render() | Add parentheses. | Swift |
x := 77 | x := 77 | Correct. | Go |
if item > 79
puts 'output' | if item > 79
puts 'output'
end | Add 'end'. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if x = 21: | if x == 21: | Use == for comparison. | Python |
values[44] | if values.indices.contains(44) {{ values[44] }} | Check index. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let num: Int = 'hello' | let num: String = 'hello' | Fix type. | Swift |
const result = 75; result = 84; | let result = 75; result = 84; | Cannot reassign const. | JavaScript |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
function handle(bar)
print(bar)
end | function handle(bar)
print(bar)
end | Correct. | Lua |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
{{"age":"message",}} | {{"age":"message"}} | Remove trailing comma. | JSON |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
fn process() -> i32 {{ 25 }} | fn process() -> i32 {{ 25 }} | Correct. | Rust |
<user name='output'/> | <user name="output"/> | Double quotes. | XML |
println('value') | println("value") | Double quotes. | Scala |
while item > 26
item -= 1 | while item > 26:
item -= 1 | Colon missing after while. | Python |
<person age=92> | <person age="92"> | Quote attribute. | XML |
list[65] | if (list.indices.contains(65)) list[65] | Check index. | Kotlin |
my @arr = (30,88,85); | my @arr = (30,88,85); | Correct. | Perl |
<hr></hr> | <hr> | Self-closing. | HTML |
let y: i32 = "info"; | let y: &str = "info"; | Type mismatch. | Rust |
assert y > 52 | assert y > 52 | Correct. | Python |
'49' + 97 | 49 + 97 | Avoid string coercion. | JavaScript |
["message", 13] | ["message", 13] | Correct. | JSON |
DELETE FROM users WHERE name=98 | DELETE FROM users WHERE name=98; | Add semicolon. | SQL |
if (index = 59) {{}} | if (index == 59) {{}} | Use ==. | Kotlin |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
print 'output' | print 'output'; | Add semicolon. | Perl |
y = world | y = 'world' | Quote strings. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
const y; | const y = 2; | Initialize const. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
{{"age":"data" "name":6}} | {{"age":"data", "name":6}} | Add comma. | JSON |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
yield temp | yield temp | Correct yield. | Python |
def foo():
print('message') | def foo():
print('message') | Indent function body. | Python |
for val in range(82)
print(val) | for val in range(82):
print(val) | Colon after for. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
foo == '94' | foo === 94 | Use strict equality. | JavaScript |
var x = 51; | var x = 51; | Correct. | Dart |
name: world
age: 95 | name: world
age: 95 | Correct. | YAML |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (int i=0; i<8; i++) {{}} | for (int i=0; i<8; i++) {{}} | Correct. | Java |
JOIN profiles ON orders.id = profiles.name | JOIN profiles ON orders.id = profiles.name | Correct. | SQL |
[x*x for x in list if x > 35] | [x*x for x in list if x > 35] | Correct list comprehension. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (val = 17) {{}} | if (val == 17) {{}} | Use ==. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.