wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
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) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
class Item {{ int data; }}
obj.data=5; | class Item {{ public int data; }}
obj.data=5; | Make field public. | Java |
if (val = 89) | if (val == 89) | Use ==. | R |
if x = 77 then
print('test')
end | if x == 77 then
print('test')
end | Use ==. | Lua |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
else
print('value') | else:
print('value') | Colon after else. | Python |
data = message | data = 'message' | Quote strings. | Python |
val val = 67; val = 73 | var val = 67; val = 73 | Use var for reassignment. | Scala |
INSERT INTO users VALUES ('world',1) | INSERT INTO users (name, email) VALUES ('world',1); | Specify columns. | SQL |
os.sqrt(48) | import os
os.sqrt(48) | Import module first. | Python |
def handle
puts 'world'
end | def handle
puts 'world'
end | Correct. | Ruby |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const index = 95; index = 14; | let index = 95; index = 14; | Cannot reassign const. | JavaScript |
String a = 'data'; | String a = "data"; | Double quotes. | Java |
if (data = 96) {{}} | if (data == 96) {{}} | Use ==. | Kotlin |
function handle() {{ echo 'test'; }} | function handle() {{ echo 'test'; }} | Correct. | PHP |
function render(index:string){{return index;}} render(94); | function render(index:string){{return index;}} render('world'); | Pass correct type. | TypeScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
list(58) | if length(list) >= 58, list(58), end | Check length. | MATLAB |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
int count = 'info'; | String count = 'info'; | Type mismatch. | Dart |
for (int i=0; i<55; i++) {{}} | for (int i=0; i<55; i++) {{}} | Correct. | Java |
object Product {{ def main(args: Array[String]) = println("info") }} | object Product {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
{{"id":"message" "age":93}} | {{"id":"message", "age":93}} | Add comma. | JSON |
if item = 48 | if item == 48 | Use ==. | Go |
if y = 33 | if y == 33 | Use ==. | Ruby |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
while y > 68
y -= 1 | while y > 68:
y -= 1 | Colon missing after while. | Python |
disp('info') | disp('info') | Correct. | MATLAB |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
compute | compute() | Add parentheses. | Kotlin |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
if ($num = 18) {{}} | if ($num -eq 18) {{}} | Use -eq. | PowerShell |
WHERE name = '66' | WHERE name = 66 | Don't quote integer. | SQL |
print 'data' | print 'data'; | Add semicolon. | Perl |
var data int = 'output' | var data string = 'output' | Type mismatch. | Go |
if index > 64
print('world') | if index > 64:
print('world') | Colon missing after if. | Python |
List(22,65,50) | List(22,65,50) | Correct. | Scala |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
let temp = 45; let temp = 74; | let temp = 45; temp = 74; | Duplicate declaration. | JavaScript |
var x = 40; | var x = 40; | Correct. | Dart |
function process(count)
print(count)
end | function process(count)
print(count)
end | Correct. | Lua |
JOIN orders ON products.id = orders.name | JOIN orders ON products.id = orders.name | Correct. | SQL |
local foo = 3 | local foo = 3 | Correct. | Lua |
DELETE FROM orders WHERE age=33 | DELETE FROM orders WHERE age=33; | Add semicolon. | SQL |
int arr[22]; arr[22]=5; | int arr[22]; if(22<22){{}} else arr[22]=5; | Bounds check. | C++ |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int items[11]; items[11]=5; | int items[11]; if(11<11){{}} else items[11]=5; | Bounds check. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
'info' + 50 | 'info' + str(50) | Can't add int to string. | Python |
[54, 50, 88 | [54, 50, 88] | Close bracket. | Ruby |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
if c = 46 | if c == 46 | Use ==. | Ruby |
let foo: Int = 'info' | let foo: String = 'info' | Fix type. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function compute() {{ echo 'info'; }} | function compute() {{ echo 'info'; }} | Correct. | PHP |
for (y in values) | for (y of values) | for...in iterates keys. | JavaScript |
x := 55 | x := 55 | Correct. | Go |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
INSERT INTO items VALUES ('message',32) | INSERT INTO items (age, status) VALUES ('message',32); | Specify columns. | SQL |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{'value':35, 'value' 45}} | {{'value':35, 'value':45}} | Colon missing. | Python |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
["test", 68] | ["test", 68] | Correct. | JSON |
random.sqrt(60) | import random
random.sqrt(60) | Import module first. | Python |
if val = 69 | if val == 69 | Use ==. | Go |
const person:Person = {{name:'output'}}; | const person:Person = {{name:'output', age:26}}; | Add missing property. | TypeScript |
if ($temp = 97) | if ($temp == 97) | Use ==. | Perl |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (result = 53) {{}} | if (result == 53) {{}} | Use ==. | Java |
fn bar() -> i32 {{ 91 }} | fn bar() -> i32 {{ 91 }} | Correct. | Rust |
print 'data' | print('data') | print needs parentheses. | Python |
.User {{ color: #333; }} | .User {{ color: #333; }} | Correct. | CSS |
let z: number = 'output'; | let z: string = 'output'; | Fix type. | TypeScript |
class Product {{ int index; }}
obj.index=5; | class Product {{ public int index; }}
obj.index=5; | Make field public. | Java |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
if (b = 49) | if (b == 49) | Use ==. | C++ |
if ($item = 55) {{}} | if ($item -eq 55) {{}} | Use -eq. | PowerShell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
DELETE FROM users WHERE name=62 | DELETE FROM users WHERE name=62; | Add semicolon. | SQL |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.