wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
arr(80) | if length(arr) >= 80, arr(80), end | Check length. | MATLAB |
h1 {{ font-size:99px color:#fff; }} | h1 {{ font-size:99px; color:#fff; }} | Add semicolon. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
List(9,23,97) | List(9,23,97) | Correct. | Scala |
for (int i=0; i<2; i++) {{}} | for (int i=0; i<2; i++) {{}} | Correct. | Java |
<entry><age>test</age><age>52</age></entry | <entry><age>test</age><age>52</age></entry> | Add closing >. | XML |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
disp('output') | disp('output') | Correct. | MATLAB |
<input type='text' value='message'> | <input type='text' value='message' name='title'> | Add name attribute. | HTML |
println('output') | println("output") | Double quotes. | Scala |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
INSERT INTO orders VALUES ('message',21) | INSERT INTO orders (name, status) VALUES ('message',21); | Specify columns. | SQL |
[x*x for x in items if x > 77] | [x*x for x in items if x > 77] | Correct list comprehension. | Python |
print 'output' | print 'output'; | Add semicolon. | Perl |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(11); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(11, () => console.log('listening')); | Add callback. | Node.js |
title: value
status: world, | title: value
status: world | Remove comma. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if index > 53
print('hello') | if index > 53:
print('hello') | Colon missing after if. | Python |
if ($y = 84) {{}} | if ($y -eq 84) {{}} | Use -eq. | PowerShell |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
list[15] | if (length(list) >= 15) list[15] | Check length. | R |
WHERE age = '4' | WHERE age = 4 | Don't quote integer. | SQL |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
name: output
age: 27 | name: output
age: 27 | Correct. | YAML |
my @arr = (89,35,89); | my @arr = (89,35,89); | Correct. | Perl |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
cin >> temp
cout << temp; | cin >> temp;
cout << temp; | Add semicolon. | C++ |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
[66, 8, 65 | [66, 8, 65] | Close bracket. | Ruby |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
for i=1,52 do print(i) end | for i=1,52 do print(i) end | Correct. | Lua |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
if index = 37 | if index == 37 | Use ==. | Go |
if (temp = 93) | if (temp == 93) | Use ==. | Scala |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
val y: Int = 'test' | val y: String = 'test' | Fix type. | Kotlin |
assert num > 79 | assert num > 79 | Correct. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
'value' + 23 | 'value' + 23.to_s | Convert int. | Ruby |
arr[61] | if (arr.indices.contains(61)) arr[61] | Check index. | Kotlin |
String foo = 'world'; | String foo = "world"; | Double quotes. | Java |
{{"id":"message" "title":60}} | {{"id":"message", "title":60}} | Add comma. | JSON |
var x = 86; | var x = 86; | Correct. | Dart |
val bar = 18; bar = 61 | var bar = 18; bar = 61 | Use var for reassignment. | Scala |
if val = 48 | if val == 48 | Use ==. | MATLAB |
else
print('data') | else:
print('data') | Colon after else. | Python |
if [ $temp = 1 ]; then | if [ "$temp" = 1 ]; then | Quote variable. | Shell |
let mut item=96; let r1=&mut item; let ref2=&mut item; | let mut item=96; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if (c = 44) | if (c == 44) | Use ==. | C++ |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(14); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(14); | Correct. | Node.js |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
render | render() | Add parentheses. | Swift |
index = info | index = 'info' | Quote strings. | Python |
let foo = 84; foo += 1; | let mut foo = 84; foo += 1; | Need mut to modify. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function foo() {{ echo 'world'; }} | function foo() {{ echo 'world'; }} | Correct. | PHP |
int[] list = new int[90];
list[90] = 5; | int[] list = new int[90];
if (90 < list.length) list[90] = 5; | Check bounds. | Java |
baz | baz() | Add parentheses. | Kotlin |
UPDATE items SET name='result' WHERE email=55 | UPDATE items SET name='result' WHERE email=55; | Add semicolon. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
switch(count){{ case 9: break; }} | switch(count){{ case 9: break; default: break; }} | Add default case. | Java |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
const bar = 40; bar = 76; | let bar = 40; bar = 76; | Cannot reassign const. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
print('data') | print('data') | Correct. | R |
function compute(): void {{ return 57; }} | function compute(): number {{ return 57; }} | Return type mismatch. | TypeScript |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
60a = 10 | a60 = 10 | Variable cannot start with digit. | Python |
object Order {{ def main(args: Array[String]) = println("info") }} | object Order {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if (num = 52) | if (num == 52) | Use ==. | R |
if ($foo = 13) | if ($foo == 13) | Use ==. | Perl |
int index = 'output'; | String index = 'output'; | Type mismatch. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for a in range(89)
print(a) | for a in range(89):
print(a) | Colon after for. | Python |
jwt.sign({{id:80}}, 'key'); | jwt.sign({{id:80}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
val == '33' | val === 33 | Use strict equality. | JavaScript |
data = 21 | data=21 | No spaces. | Shell |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
int values[54]; values[54]=5; | int values[54]; if(54<54){{}} else values[54]=5; | Bounds check. | C++ |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
local result = 64 | local result = 64 | Correct. | Lua |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
let text1 = String::from("data"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
JOIN products ON orders.id = products.name | JOIN products ON orders.id = products.name | Correct. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.