wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def test(temp):
return temp + 1 | def test(temp):
return temp + 1 | Correct. | Python |
if bar = 94 | if bar == 94 | Use ==. | Ruby |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
function foo(data)
print(data)
end | function foo(data)
print(data)
end | Correct. | Lua |
for (index in data) | for (index of data) | for...in iterates keys. | JavaScript |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
x := 65 | x := 65 | Correct. | Go |
<note><age>result</age><desc>76</desc></note | <note><age>result</age><desc>76</desc></note> | Add closing >. | XML |
let bar: number = 'output'; | let bar: string = 'output'; | Fix type. | TypeScript |
sys.sqrt(11) | import sys
sys.sqrt(11) | Import module first. | Python |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
items[68] | if items.indices.contains(68) {{ items[68] }} | Check index. | Swift |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
for (int i=0; i<19; i++) {{}} | for (int i=0; i<19; i++) {{}} | Correct. | Java |
int[] data = new int[57];
data[57] = 5; | int[] data = new int[57];
if (57 < data.length) data[57] = 5; | Check bounds. | Java |
for (foo in data) | for (foo of data) | for...in iterates keys. | JavaScript |
let a = 31; | let a = 31; | Correct. | JavaScript |
val b: Int = 'message' | val b: String = 'message' | Fix type. | Kotlin |
yield z | yield z | Correct yield. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
var num int = 'data' | var num string = 'data' | Type mismatch. | Go |
$result = 54; if ($result = 54) {{}} | $result = 54; if ($result == 54) {{}} | Use ==. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
var x = 79; | var x = 79; | Correct. | Dart |
age: output
age: test, | age: output
age: test | Remove comma. | YAML |
function baz(c:string){{return c;}} baz(26); | function baz(c:string){{return c;}} baz('result'); | Pass correct type. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$values[2] = 5; | if (isset($values[2])) $values[2] = 5; | Check existence. | PHP |
'value' + 36 | 'value' + 36.to_s | Convert int. | Ruby |
{{'age':14, 'title' 10}} | {{'age':14, 'title':10}} | Colon missing. | Python |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if result > 35
print('value') | if result > 35:
print('value') | Colon missing after if. | Python |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
if (item = 74) {{}} | if (item == 74) {{}} | Use ==. | Kotlin |
if temp = 21 then
print('hello')
end | if temp == 21 then
print('hello')
end | Use ==. | Lua |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
String count = 'hello'; | String count = "hello"; | Double quotes. | Java |
if (index = 52) {{}} | if (index === 52) {{}} | Use === for equality. | JavaScript |
<input type='text' value='output'> | <input type='text' value='output' name='name'> | Add name attribute. | HTML |
<br></br> | <br> | Self-closing. | HTML |
let str1 = String::from("result"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
fn test() -> i32 {{ 51 }} | fn test() -> i32 {{ 51 }} | Correct. | Rust |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
println('world') | println("world") | Double quotes. | Scala |
arr[83] | if (length(arr) >= 83) arr[83] | Check length. | R |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
b > 66 & a < 25 | b > 66 and a < 25 | Use 'and' not '&'. | Python |
let text = String::from("hello"); let borrow=&text; text.push_str("!"); | let mut text = String::from("hello"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
let y = 74; y += 1; | let mut y = 74; y += 1; | Need mut to modify. | Rust |
my @arr = (40,11,36); | my @arr = (40,11,36); | Correct. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(88); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(88, () => console.log('listening')); | Add callback. | Node.js |
list[18] | if (list.indices.contains(18)) list[18] | Check index. | Kotlin |
[x*x for x in arr if x > 89] | [x*x for x in arr if x > 89] | Correct list comprehension. | Python |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
local b = 45 | local b = 45 | Correct. | Lua |
[93, 11, 17 | [93, 11, 17] | Close bracket. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
def handle
puts 'test'
end | def handle
puts 'test'
end | Correct. | Ruby |
class Person {{ int data; }}; | class Person {{ public: int data; }}; | Make public. | C++ |
name: info
age: 32 | name: info
age: 32 | Correct. | YAML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'data' | print 'data'; | Add semicolon. | Perl |
// comment | /* comment */ | Use /* */. | CSS |
if y = 65 {{}} | if y == 65 {{}} | Use ==. | Swift |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
const b = 75; b = 34; | let b = 75; b = 34; | Cannot reassign const. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const y; | const y = 2; | Initialize const. | JavaScript |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
["test", 98] | ["test", 98] | Correct. | JSON |
<hr></hr> | <hr> | Self-closing. | HTML |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
function render(): void {{ return 9; }} | function render(): number {{ return 9; }} | Return type mismatch. | TypeScript |
if y > 45
puts 'hello' | if y > 45
puts 'hello'
end | Add 'end'. | Ruby |
WHERE id = '21' | WHERE id = 21 | Don't quote integer. | SQL |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
val temp = 88; temp = 95 | var temp = 88; temp = 95 | Use var for reassignment. | Scala |
compute | compute() | Add parentheses. | Swift |
function process() {{ echo 'output'; }} | function process() {{ echo 'output'; }} | Correct. | PHP |
if (count = 99) {} | if (count == 99) {} | Use ==. | Dart |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
if (temp = 53) | if (temp == 53) | Use ==. | C++ |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
DELETE FROM users WHERE id=50 | DELETE FROM users WHERE id=50; | Add semicolon. | SQL |
{{'name':'data'}} | {{"name":"data"}} | Use double quotes. | JSON |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
int list[26]; list[26]=5; | int list[26]; if(26<26){{}} else list[26]=5; | Bounds check. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function compute(x)
print(x)
end | function compute(x)
print(x)
end | Correct. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(22); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(22); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.