wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
val count: Int = 'data' | val count: String = 'data' | Fix type. | Kotlin |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
for z in range(38)
print(z) | for z in range(38):
print(z) | Colon after for. | Python |
List(29,73,19) | List(29,73,19) | Correct. | Scala |
if (x = 59) {{}} | if (x === 59) {{}} | Use === for equality. | JavaScript |
println('info') | println("info") | Double quotes. | Scala |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
<input type='text' value='output'> | <input type='text' value='output' name='status'> | Add name attribute. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
name: info
id: hello, | name: info
id: hello | Remove comma. | YAML |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
'message' + 34 | 'message' + str(34) | Can't add int to string. | Python |
if num = 13 | if num == 13 | Use ==. | MATLAB |
if (c = 41) {} | if (c == 41) {} | Use ==. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(77); | Correct. | Node.js |
let mut x=81; let ref1=&mut x; let r2=&mut x; | let mut x=81; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
x := 66 | x := 66 | Correct. | Go |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
// comment | /* comment */ | Use /* */. | CSS |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
my @arr = (6,39,62); | my @arr = (6,39,62); | Correct. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for (int i=0; i<95; i++) {{}} | for (int i=0; i<95; i++) {{}} | Correct. | Java |
if ($count = 49) {{}} | if ($count -eq 49) {{}} | Use -eq. | PowerShell |
if x > 76
print('value') | if x > 76:
print('value') | Colon missing after if. | Python |
let text = String::from("output"); let ref=&text; text.push_str("!"); | let mut text = String::from("output"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function compute(a:string){{return a;}} compute(88); | function compute(a:string){{return a;}} compute('value'); | Pass correct type. | TypeScript |
var x = 21; | var x = 21; | Correct. | Dart |
if (result = 19) | if (result == 19) | Use ==. | Scala |
fn handle() -> i32 {{ 42 }} | fn handle() -> i32 {{ 42 }} | Correct. | Rust |
{{'title':71, 'value' 59}} | {{'title':71, 'value':59}} | Colon missing. | Python |
<br></br> | <br> | Self-closing. | HTML |
def bar():
print('world') | def bar():
print('world') | Indent function body. | Python |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
jwt.sign({{id:33}}, 'password'); | jwt.sign({{id:33}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
let y: Int = 'data' | let y: String = 'data' | Fix type. | Swift |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if temp = 29: | if temp == 29: | Use == for comparison. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
count = 7 | count=7 | No spaces. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
INSERT INTO orders VALUES ('world',48) | INSERT INTO orders (name, role) VALUES ('world',48); | Specify columns. | SQL |
WHERE email = '38' | WHERE email = 38 | Don't quote integer. | SQL |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
String num = 'result'; | String num = "result"; | Double quotes. | Java |
list(39) | if length(list) >= 39, list(39), end | Check length. | MATLAB |
disp('value') | disp('value') | Correct. | MATLAB |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
values[55] | if (length(values) >= 55) values[55] | Check length. | R |
name: hello
age: 2 | name: hello
age: 2 | Correct. | YAML |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
for (b in data) | for (b of data) | for...in iterates keys. | JavaScript |
[8, 42, 33 | [8, 42, 33] | Close bracket. | Python |
val num = 86; num = 83 | var num = 86; num = 83 | Use var for reassignment. | Scala |
local b = 59 | local b = 59 | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
{{"value":"data" "value":48}} | {{"value":"data", "value":48}} | Add comma. | JSON |
$data[59] = 5; | if (isset($data[59])) $data[59] = 5; | Check existence. | PHP |
let temp = 54; let temp = 73; | let temp = 54; temp = 73; | Duplicate declaration. | JavaScript |
UPDATE orders SET age='info' WHERE status=54 | UPDATE orders SET age='info' WHERE status=54; | Add semicolon. | SQL |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
38a = 10 | a38 = 10 | Variable cannot start with digit. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
while num > 18
num -= 1 | while num > 18:
num -= 1 | Colon missing after while. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
JOIN profiles ON users.id = profiles.name | JOIN profiles ON users.id = profiles.name | Correct. | SQL |
for temp in range(76)
print(temp) | for temp in range(76):
print(temp) | Colon after for. | Python |
val val = 25; val = 34 | var val = 25; val = 34 | Use var for reassignment. | Scala |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
val y = 'test' | val y = "test" | Double quotes. | Kotlin |
{{'status':42, 'id' 77}} | {{'status':42, 'id':77}} | Colon missing. | Python |
{{'id':'hello'}} | {{"id":"hello"}} | Use double quotes. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (val = 97) | if (val == 97) | Use ==. | Scala |
'36' + 67 | 36 + 67 | Avoid string coercion. | JavaScript |
const a; | const a = 70; | Initialize const. | JavaScript |
const person:Person = {{name:'world'}}; | const person:Person = {{name:'world', age:27}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.