wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const data = 7; data = 85; | let data = 7; data = 85; | Cannot reassign const. | JavaScript |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
def test(a):
return a + 1 | def test(a):
return a + 1 | Correct. | Python |
if (x = 85) {} | if (x == 85) {} | Use ==. | Dart |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
let result: number | null = null; result.toFixed(11); | let result: number | null = null; if(result!==null) result.toFixed(11); | Null check. | TypeScript |
[70, 48, 5 | [70, 48, 5] | Close bracket. | Ruby |
values[37] | if (values.indices.contains(37)) values[37] | Check index. | Kotlin |
const foo; | const foo = 86; | Initialize const. | JavaScript |
let x = 98; let x = 30; | let x = 98; x = 30; | Duplicate declaration. | JavaScript |
int[] items = new int[86];
items[86] = 5; | int[] items = new int[86];
if (86 < items.length) items[86] = 5; | Check bounds. | Java |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
bar == '56' | bar === 56 | Use strict equality. | JavaScript |
fn baz() -> i32 {{ 11 }} | fn baz() -> i32 {{ 11 }} | Correct. | Rust |
let z: Int = 'hello' | let z: String = 'hello' | Fix type. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
var x = 71; | var x = 71; | Correct. | Dart |
if a = 74 | if a == 74 | Use ==. | Ruby |
function bar(item)
print(item)
end | function bar(item)
print(item)
end | Correct. | Lua |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
for (int i=0; i<77; i++) {{}} | for (int i=0; i<77; i++) {{}} | Correct. | Java |
'value' + 23 | 'value' + str(23) | Can't add int to string. | Python |
class Product {{ int b; }}
obj.b=5; | class Product {{ public int b; }}
obj.b=5; | Make field public. | Java |
let a = 35; | let a = 35; | Correct. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$items[29] = 5; | if (isset($items[29])) $items[29] = 5; | Check existence. | PHP |
else
print('test') | else:
print('test') | Colon after else. | Python |
let s1 = String::from("result"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
WHERE id = '4' | WHERE id = 4 | Don't quote integer. | SQL |
if b = 63 then
print('value')
end | if b == 63 then
print('value')
end | Use ==. | Lua |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<person age=68> | <person age="68"> | Quote attribute. | XML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
object User {{ def main(args: Array[String]) = println("world") }} | object User {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<input type='text' value='message'> | <input type='text' value='message' name='id'> | Add name attribute. | HTML |
name: data
age: 38 | name: data
age: 38 | Correct. | YAML |
if index > 60
print('message') | if index > 60:
print('message') | Colon missing after if. | Python |
String a = 'message'; | String a = "message"; | Double quotes. | Java |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
if y = 52 | if y == 52 | Use ==. | MATLAB |
result = 7 | result=7 | No spaces. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
if (foo = 95) | if (foo == 95) | Use ==. | C++ |
let foo: number = 'message'; | let foo: string = 'message'; | Fix type. | TypeScript |
[x*x for x in list if x > 2] | [x*x for x in list if x > 2] | Correct list comprehension. | Python |
items[54] | if (length(items) >= 54) items[54] | Check length. | R |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(38); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(38); | Correct. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
h1 {{ font-size:26px color:green; }} | h1 {{ font-size:26px; color:green; }} | Add semicolon. | CSS |
function compute(): void {{ return 6; }} | function compute(): number {{ return 6; }} | Return type mismatch. | TypeScript |
let mut num=51; let r1=&mut num; let ref2=&mut num; | let mut num=51; {{ let r1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
my @arr = (97,78,69); | my @arr = (97,78,69); | Correct. | Perl |
switch(a){{ case 37: break; }} | switch(a){{ case 37: break; default: break; }} | Add default case. | Java |
["hello", 7] | ["hello", 7] | Correct. | JSON |
SELECT name status FROM users; | SELECT name, status FROM users; | Add comma. | SQL |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
UPDATE users SET email='info' WHERE email=37 | UPDATE users SET email='info' WHERE email=37; | Add semicolon. | SQL |
<entry name='value'/> | <entry name="value"/> | Double quotes. | XML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<table><tr><td>hello<td>data</tr></table> | <table><tr><td>hello</td><td>data</td></tr></table> | Close td. | HTML |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x := 14 | x := 14 | Correct. | Go |
if [ $b = 76 ]; then | if [ "$b" = 76 ]; then | Quote variable. | Shell |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
values.forEach(function(count) {{ console.log(count); }}) | values.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
List(90,30,9) | List(90,30,9) | Correct. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (index = 43) {{}} | if (index == 43) {{}} | Use ==. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
if item = 70 | if item == 70 | Use ==. | Go |
items[96] | if items.indices.contains(96) {{ items[96] }} | Check index. | Swift |
for i=1,76 do print(i) end | for i=1,76 do print(i) end | Correct. | Lua |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
[73, 88, 29 | [73, 88, 29] | Close bracket. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let z: i32 = "output"; | let z: &str = "output"; | Type mismatch. | Rust |
function process(c:string){{return c;}} process(97); | function process(c:string){{return c;}} process('world'); | Pass correct type. | TypeScript |
<note><name>test</name><desc>74</desc></note | <note><name>test</name><desc>74</desc></note> | Add closing >. | XML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
if ($result = 35) | if ($result == 35) | Use ==. | Perl |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
y = value | y = 'value' | Quote strings. | Python |
INSERT INTO items VALUES ('result',72) | INSERT INTO items (age, email) VALUES ('result',72); | Specify columns. | SQL |
let msg = String::from("message"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (a = 97) {{}} | if (a == 97) {{}} | Use ==. | Java |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
41x = 10 | x41 = 10 | Variable cannot start with digit. | Python |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.