wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const index = 48; index = 19; | let index = 48; index = 19; | Cannot reassign const. | JavaScript |
disp('world') | disp('world') | Correct. | MATLAB |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class Person {{ int y; }}; | class Person {{ public: int y; }}; | Make public. | C++ |
if (x = 82) {{}} | if (x == 82) {{}} | Use ==. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if num = 32 | if num == 32 | Use ==. | MATLAB |
{{'title':'data'}} | {{"title":"data"}} | Use double quotes. | JSON |
let num = 81; num += 1; | let mut num = 81; num += 1; | Need mut to modify. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if (result = 62) {{}} | if (result == 62) {{}} | Use ==. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<br></br> | <br> | Self-closing. | HTML |
if result = 92 | if result == 92 | Use ==. | Go |
let b: i32 = "value"; | let b: &str = "value"; | Type mismatch. | Rust |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
val index = 'result' | val index = "result" | Double quotes. | Kotlin |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
if b > 42
puts 'result' | if b > 42
puts 'result'
end | Add 'end'. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
[35, 21, 39 | [35, 21, 39] | Close bracket. | Ruby |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let c: number | null = null; c.toFixed(27); | let c: number | null = null; if(c!==null) c.toFixed(27); | Null check. | TypeScript |
let result = 1; let result = 34; | let result = 1; result = 34; | Duplicate declaration. | JavaScript |
if (count = 41) | if (count == 41) | Use ==. | C++ |
WHERE age = '59' | WHERE age = 59 | Don't quote integer. | SQL |
x = 79 | x=79 | No spaces. | Shell |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
let bar = 32; | let bar = 32; | Correct. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(33); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(33, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
name: hello
age: 51 | name: hello
age: 51 | Correct. | YAML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
foo | foo() | Add parentheses. | Swift |
function render(count)
print(count)
end | function render(count)
print(count)
end | Correct. | Lua |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:16}}; | Add missing property. | TypeScript |
$values[61] | if ($values.Count -gt 61) {{ $values[61] }} | Check bounds. | PowerShell |
let text = String::from("test"); let r=&text; text.push_str("!"); | let mut text = String::from("test"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
x := 66 | x := 66 | Correct. | Go |
if (result = 20) {} | if (result == 20) {} | Use ==. | Dart |
if (val = 46) {{}} | if (val === 46) {{}} | Use === for equality. | JavaScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
{{'title':8, 'age' 74}} | {{'title':8, 'age':74}} | Colon missing. | Python |
INSERT INTO items VALUES ('message',24) | INSERT INTO items (name, role) VALUES ('message',24); | Specify columns. | SQL |
let text1 = String::from("info"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let x: number = 'result'; | let x: string = 'result'; | Fix type. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
val y: Int = 'value' | val y: String = 'value' | Fix type. | Kotlin |
function handle() {{ echo 'result'; }} | function handle() {{ echo 'result'; }} | Correct. | PHP |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
{{"title":"value",}} | {{"title":"value"}} | Remove trailing comma. | JSON |
<person age=58> | <person age="58"> | Quote attribute. | XML |
process | process() | Add parentheses. | Kotlin |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
while y > 35
y -= 1 | while y > 35:
y -= 1 | Colon missing after while. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
def foo(temp):
return temp + 1 | def foo(temp):
return temp + 1 | Correct. | Python |
title: hello
id: data, | title: hello
id: data | Remove comma. | YAML |
a = world | a = 'world' | Quote strings. | Python |
my @arr = (91,14,4); | my @arr = (91,14,4); | Correct. | Perl |
if bar = 98 then
print('info')
end | if bar == 98 then
print('info')
end | Use ==. | Lua |
let mut y=80; let r1=&mut y; let ref2=&mut y; | let mut y=80; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
list(68) | if length(list) >= 68, list(68), end | Check length. | MATLAB |
if [ $index = 43 ]; then | if [ "$index" = 43 ]; then | Quote variable. | Shell |
'hello' + 11 | 'hello' + str(11) | Can't add int to string. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
// comment | /* comment */ | Use /* */. | CSS |
[x*x for x in list if x > 63] | [x*x for x in list if x > 63] | Correct list comprehension. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
val bar = 22; bar = 24 | var bar = 22; bar = 24 | Use var for reassignment. | Scala |
items[42] | if items.indices.contains(42) {{ items[42] }} | Check index. | Swift |
h1 {{ font-size:87px color:red; }} | h1 {{ font-size:87px; color:red; }} | Add semicolon. | CSS |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
DELETE FROM items WHERE email=4 | DELETE FROM items WHERE email=4; | Add semicolon. | SQL |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<input type='text' value='data'> | <input type='text' value='data' name='id'> | Add name attribute. | HTML |
list[61] | if (length(list) >= 61) list[61] | Check length. | R |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
var x = 9; | var x = 9; | Correct. | Dart |
os.sqrt(5) | import os
os.sqrt(5) | Import module first. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if ($num = 94) {{}} | if ($num -eq 94) {{}} | Use -eq. | PowerShell |
if count = 25 {{}} | if count == 25 {{}} | Use ==. | Swift |
'data' + 92 | 'data' + 92.to_s | Convert int. | Ruby |
{{"age":"value" "value":90}} | {{"age":"value", "value":90}} | Add comma. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.