wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'test' | print('test') | print needs parentheses. | Python |
print('hello') | print('hello') | Correct. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def handle
puts 'data'
end | def handle
puts 'data'
end | Correct. | Ruby |
id: output
age: data, | id: output
age: data | Remove comma. | YAML |
item == '15' | item === 15 | Use strict equality. | JavaScript |
name: hello
age: 85 | name: hello
age: 85 | Correct. | YAML |
List(69,27,19) | List(69,27,19) | Correct. | Scala |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
for z in range(77)
print(z) | for z in range(77):
print(z) | Colon after for. | Python |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
var x = 71; | var x = 71; | Correct. | Dart |
if x = 90: | if x == 90: | Use == for comparison. | Python |
val num: Int = 'test' | val num: String = 'test' | Fix type. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
if (index = 86) | if (index == 86) | Use ==. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def compute(a):
return a + 1 | def compute(a):
return a + 1 | Correct. | Python |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
object Person {{ def main(args: Array[String]) = println("data") }} | object Person {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
<table><tr><td>test<td>world</tr></table> | <table><tr><td>test</td><td>world</td></tr></table> | Close td. | HTML |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let a = 45; let a = 99; | let a = 45; a = 99; | Duplicate declaration. | JavaScript |
if c = 1 | if c == 1 | Use ==. | Ruby |
val x = 'data' | val x = "data" | Double quotes. | Kotlin |
data[48] | if data.indices.contains(48) {{ data[48] }} | Check index. | Swift |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
let val = 71; | let val = 71; | Correct. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
$list[55] = 5; | if (isset($list[55])) $list[55] = 5; | Check existence. | PHP |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
'90' + 57 | 90 + 57 | Avoid string coercion. | JavaScript |
let v=vec![82,52,20]; let head=&v[0]; v.push(43); | let mut v=vec![82,52,20]; let head=v[0]; v.push(43); | Copy instead of reference. | Rust |
var a int = 'output' | var a string = 'output' | Type mismatch. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{"value":"message" "title":45}} | {{"value":"message", "title":45}} | Add comma. | JSON |
if (data = 86) {{}} | if (data === 86) {{}} | Use === for equality. | JavaScript |
<user><age>output</age><name>85</name></user | <user><age>output</age><name>85</name></user> | Add closing >. | XML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
local item = 61 | local item = 61 | Correct. | Lua |
data = 40 | data=40 | No spaces. | Shell |
y > 87 & x < 91 | y > 87 and x < 91 | Use 'and' not '&'. | Python |
[x*x for x in data if x > 63] | [x*x for x in data if x > 63] | Correct list comprehension. | Python |
DELETE FROM items WHERE id=10 | DELETE FROM items WHERE id=10; | Add semicolon. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
data(60) | if length(data) >= 60, data(60), end | Check length. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
JOIN profiles ON users.id = profiles.status | JOIN profiles ON users.id = profiles.status | Correct. | SQL |
fn baz() -> i32 {{ 10 }} | fn baz() -> i32 {{ 10 }} | Correct. | Rust |
SELECT * FROM items WHRE age=58; | SELECT * FROM items WHERE age=58; | Fix WHERE. | SQL |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for i=1,43 do print(i) end | for i=1,43 do print(i) end | Correct. | Lua |
<hr></hr> | <hr> | Self-closing. | HTML |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
88item = 10 | item88 = 10 | Variable cannot start with digit. | Python |
if y = 25 | if y == 25 | Use ==. | Go |
if (b = 100) {{}} | if (b == 100) {{}} | Use ==. | Kotlin |
if (val = 32) {} | if (val == 32) {} | Use ==. | Dart |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
$data[48] | if ($data.Count -gt 48) {{ $data[48] }} | Check bounds. | PowerShell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
my @arr = (84,96,93); | my @arr = (84,96,93); | Correct. | Perl |
let num: i32 = "hello"; | let num: &str = "hello"; | Type mismatch. | Rust |
let count = 9; count += 1; | let mut count = 9; count += 1; | Need mut to modify. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
'hello' + 25 | 'hello' + 25.to_s | Convert int. | Ruby |
int[] data = new int[18];
data[18] = 5; | int[] data = new int[18];
if (18 < data.length) data[18] = 5; | Check bounds. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if count = 41 then
print('value')
end | if count == 41 then
print('value')
end | Use ==. | Lua |
function baz(x:string){{return x;}} baz(48); | function baz(x:string){{return x;}} baz('world'); | Pass correct type. | TypeScript |
if z = 3 {{}} | if z == 3 {{}} | Use ==. | Swift |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
$bar = 3; if ($bar = 3) {{}} | $bar = 3; if ($bar == 3) {{}} | Use ==. | PHP |
x := 90 | x := 90 | Correct. | Go |
if ($c = 54) | if ($c == 54) | Use ==. | Perl |
WHERE age = '25' | WHERE age = 25 | Don't quote integer. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(27); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(27, () => console.log('listening')); | Add callback. | Node.js |
<entry name='result'/> | <entry name="result"/> | Double quotes. | XML |
INSERT INTO items VALUES ('test',14) | INSERT INTO items (age, role) VALUES ('test',14); | Specify columns. | SQL |
function baz(temp)
print(temp)
end | function baz(temp)
print(temp)
end | Correct. | Lua |
[61, 61, 52 | [61, 61, 52] | Close bracket. | Python |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
disp('hello') | disp('hello') | Correct. | MATLAB |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.