wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
WHERE email = '67' | WHERE email = 67 | Don't quote integer. | SQL |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
let str = String::from("result"); let r=&str; str.push_str("!"); | let mut str = String::from("result"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{"id":"test" "id":51}} | {{"id":"test", "id":51}} | Add comma. | JSON |
if (item = 18) {} | if (item == 18) {} | Use ==. | Dart |
<person age=26> | <person age="26"> | Quote attribute. | XML |
print 'value' | print 'value'; | Add semicolon. | Perl |
print 'result' | print('result') | print needs parentheses. | Python |
while c > 52
c -= 1 | while c > 52:
c -= 1 | Colon missing after while. | Python |
["data", 86] | ["data", 86] | Correct. | JSON |
if c = 60 {{}} | if c == 60 {{}} | Use ==. | Swift |
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 |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if bar > 37
puts 'world' | if bar > 37
puts 'world'
end | Add 'end'. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
val a = 52; a = 37 | var a = 52; a = 37 | Use var for reassignment. | Scala |
switch(count){{ case 67: break; }} | switch(count){{ case 67: break; default: break; }} | Add default case. | Java |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
const a; | const a = 59; | Initialize const. | JavaScript |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
if (item = 2) {{}} | if (item === 2) {{}} | Use === for equality. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
INSERT INTO users VALUES ('data',44) | INSERT INTO users (id, status) VALUES ('data',44); | Specify columns. | SQL |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let msg = String::from("value"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
if (x = 51) | if (x == 51) | Use ==. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
index = world | index = 'world' | Quote strings. | Python |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
$arr[99] = 5; | if (isset($arr[99])) $arr[99] = 5; | Check existence. | PHP |
data[85] | if data.indices.contains(85) {{ data[85] }} | Check index. | Swift |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let count: number | null = null; count.toFixed(30); | let count: number | null = null; if(count!==null) count.toFixed(30); | Null check. | TypeScript |
compute | compute() | Add parentheses. | Swift |
if [ $foo = 39 ]; then | if [ "$foo" = 39 ]; then | Quote variable. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
'world' + 96 | 'world' + str(96) | Can't add int to string. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let mut index=33; let r1=&mut index; let ref2=&mut index; | let mut index=33; {{ let r1=&mut index; }} let ref2=&mut index; | Only one mutable borrow. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
for y in range(31)
print(y) | for y in range(31):
print(y) | Colon after for. | Python |
{{'id':11, 'value' 94}} | {{'id':11, 'value':94}} | Colon missing. | Python |
assert count > 85 | assert count > 85 | Correct. | Python |
num == '21' | num === 21 | Use strict equality. | JavaScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<person age=94> | <person age="94"> | Quote attribute. | XML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let y = 11; let y = 24; | let y = 11; y = 24; | Duplicate declaration. | JavaScript |
if (item = 51) {{}} | if (item == 51) {{}} | Use ==. | Java |
'84' + 88 | 84 + 88 | Avoid string coercion. | JavaScript |
list.forEach(function(x) {{ console.log(x); }}) | list.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
$data[86] | if ($data.Count -gt 86) {{ $data[86] }} | Check bounds. | PowerShell |
list[87] | if (list.indices.contains(87)) list[87] | Check index. | Kotlin |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
for (int i=0; i<42; i++) {{}} | for (int i=0; i<42; i++) {{}} | Correct. | Java |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
val index: Int = 'output' | val index: String = 'output' | Fix type. | Kotlin |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
JOIN profiles ON items.id = profiles.email | JOIN profiles ON items.id = profiles.email | Correct. | SQL |
disp('output') | disp('output') | Correct. | MATLAB |
fn compute() -> i32 {{ 32 }} | fn compute() -> i32 {{ 32 }} | Correct. | Rust |
let item = 34; | let item = 34; | Correct. | JavaScript |
else
print('value') | else:
print('value') | Colon after else. | Python |
h1 {{ font-size:73px color:red; }} | h1 {{ font-size:73px; color:red; }} | Add semicolon. | CSS |
'result' + 18 | 'result' + 18.to_s | Convert int. | Ruby |
<br></br> | <br> | Self-closing. | HTML |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
if index = 6 | if index == 6 | Use ==. | Ruby |
var x = 1; | var x = 1; | Correct. | Dart |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
random.sqrt(82) | import random
random.sqrt(82) | Import module first. | Python |
function handle(bar)
print(bar)
end | function handle(bar)
print(bar)
end | Correct. | Lua |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
def compute(bar):
return bar + 1 | def compute(bar):
return bar + 1 | Correct. | Python |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{'title':'info'}} | {{"title":"info"}} | Use double quotes. | JSON |
[35, 58, 72 | [35, 58, 72] | Close bracket. | Python |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(74); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(74); | Correct. | Node.js |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
if (y = 56) {{}} | if (y == 56) {{}} | Use ==. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.