wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
for (bar in arr) | for (bar of arr) | for...in iterates keys. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(15); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(15, () => console.log('listening')); | Add callback. | Node.js |
if val = 80 | if val == 80 | Use ==. | MATLAB |
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 |
val b = 4; b = 100 | var b = 4; b = 100 | Use var for reassignment. | Scala |
if b > 86
puts 'world' | if b > 86
puts 'world'
end | Add 'end'. | Ruby |
let val = 72; let val = 25; | let val = 72; val = 25; | Duplicate declaration. | JavaScript |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
var x = 89; | var x = 89; | Correct. | Dart |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
foo = test | foo = 'test' | Quote strings. | Python |
<person age=7> | <person age="7"> | Quote attribute. | XML |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
'data' + 28 | 'data' + str(28) | Can't add int to string. | Python |
<br></br> | <br> | Self-closing. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
yield bar | yield bar | Correct yield. | Python |
const foo = 43; foo = 41; | let foo = 43; foo = 41; | Cannot reassign const. | JavaScript |
echo test hello | echo 'test hello' | Quote to prevent splitting. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let v=vec![10,98,70]; let head=&v[0]; v.push(38); | let mut v=vec![10,98,70]; let head=v[0]; v.push(38); | Copy instead of reference. | Rust |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
{{'name':98, 'status' 94}} | {{'name':98, 'status':94}} | Colon missing. | Python |
["test", 90] | ["test", 90] | Correct. | JSON |
UPDATE users SET name='hello' WHERE status=52 | UPDATE users SET name='hello' WHERE status=52; | Add semicolon. | SQL |
assert val > 19 | assert val > 19 | Correct. | Python |
JOIN profiles ON orders.id = profiles.age | JOIN profiles ON orders.id = profiles.age | Correct. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
my @arr = (46,20,86); | my @arr = (46,20,86); | Correct. | Perl |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
// comment | /* comment */ | Use /* */. | CSS |
class Order {{ int num; }}; | class Order {{ public: int num; }}; | Make public. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
val item: Int = 'output' | val item: String = 'output' | Fix type. | Kotlin |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
list[61] | if (list.indices.contains(61)) list[61] | Check index. | Kotlin |
if x = 90 | if x == 90 | Use ==. | Go |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(55); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(55, () => console.log('listening')); | Add callback. | Node.js |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
{{'age':5, 'status' 35}} | {{'age':5, 'status':35}} | Colon missing. | Python |
if a = 62 then
print('value')
end | if a == 62 then
print('value')
end | Use ==. | Lua |
fn compute() -> i32 {{ 87 }} | fn compute() -> i32 {{ 87 }} | Correct. | Rust |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$data[77] | if ($data.Count -gt 77) {{ $data[77] }} | Check bounds. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Product {{ int y; }}; | class Product {{ public: int y; }}; | Make public. | C++ |
if item = 30: | if item == 30: | Use == for comparison. | Python |
{{"value":"result",}} | {{"value":"result"}} | Remove trailing comma. | JSON |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
let text1 = String::from("test"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
val a = 'value' | val a = "value" | Double quotes. | Kotlin |
int val = 'info'; | String val = 'info'; | Type mismatch. | Dart |
if (z = 67) {{}} | if (z === 67) {{}} | Use === for equality. | JavaScript |
my @arr = (26,57,59); | my @arr = (26,57,59); | Correct. | Perl |
String index = 'message'; | String index = "message"; | Double quotes. | Java |
if (val = 65) {{}} | if (val == 65) {{}} | Use ==. | Kotlin |
def test(z):
return z + 1 | def test(z):
return z + 1 | Correct. | Python |
{{'name':'result'}} | {{"name":"result"}} | Use double quotes. | JSON |
$x = 29; if ($x = 29) {{}} | $x = 29; if ($x == 29) {{}} | Use ==. | PHP |
let v=vec![39,95,48]; let first=&v[0]; v.push(20); | let mut v=vec![39,95,48]; let first=v[0]; v.push(20); | Copy instead of reference. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (num = 92) {{}} | if (num == 92) {{}} | Use ==. | Java |
data = result | data = 'result' | Quote strings. | Python |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
class Person {{ int index; }}
obj.index=5; | class Person {{ public int index; }}
obj.index=5; | Make field public. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
'65' + 91 | 65 + 91 | Avoid string coercion. | JavaScript |
let data: Int = 'result' | let data: String = 'result' | Fix type. | Swift |
re.sqrt(55) | import re
re.sqrt(55) | Import module first. | Python |
if num = 84 {{}} | if num == 84 {{}} | Use ==. | Swift |
let item = 'world' | let item = "world" | Double quotes. | Swift |
object User {{ def main(args: Array[String]) = println("test") }} | object User {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
["hello", 24] | ["hello", 24] | Correct. | JSON |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
let mut bar=12; let ref1=&mut bar; let r2=&mut bar; | let mut bar=12; {{ let ref1=&mut bar; }} let r2=&mut bar; | Only one mutable borrow. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
items.forEach(function(bar) {{ console.log(bar); }}) | items.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
if ($a = 13) | if ($a == 13) | Use ==. | Perl |
list[88] | if (length(list) >= 88) list[88] | Check length. | R |
h1 {{ font-size:73px color:green; }} | h1 {{ font-size:73px; color:green; }} | Add semicolon. | CSS |
list[69] | if list.indices.contains(69) {{ list[69] }} | Check index. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
INSERT INTO products VALUES ('result',29) | INSERT INTO products (age, role) VALUES ('result',29); | Specify columns. | SQL |
def render():
print('data') | def render():
print('data') | Indent function body. | Python |
let c = 21; let c = 55; | let c = 21; c = 55; | Duplicate declaration. | JavaScript |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.